菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
80
0

Aspose.Cells 导出 excel

原创
05/13 14:22
阅读数 9695

Aspose.Cells.Workbook book = new Aspose.Cells.Workbook();
Aspose.Cells.Worksheet sheet = book.Worksheets["Sheet1"];
sheet.FreezePanes(1, 1, 1, 0);

Aspose.Cells.Style style = book.Styles[book.Styles.Add()];
style.Pattern = Aspose.Cells.BackgroundType.Solid;


style.Borders.SetStyle(Aspose.Cells.CellBorderType.Thin);
style.Borders.SetColor(System.Drawing.Color.LightSteelBlue);
style.IsTextWrapped = true;
style.Font.Size = 10;


Aspose.Cells.StyleFlag flag = new Aspose.Cells.StyleFlag();
flag.All = true;

sheet.Cells.ApplyStyle(style, flag);

style.VerticalAlignment = Aspose.Cells.TextAlignmentType.Center;
style.Font.IsBold = true;
flag.All = true;

sheet.Cells.Rows[0].ApplyStyle(style, flag);

sheet.Cells.ImportDataTable(dt, true, 0, 0, dt.Rows.Count, dt.Columns.Count, false, "yyyy-MM-dd", false);

book.Save(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx", Aspose.Cells.FileFormatType.Excel2007Xlsx, Aspose.Cells.SaveType.OpenInExcel, Response);

发表评论

0/200
80 点赞
0 评论
收藏