我正在使用SoftArtisans OfficeWriter工具创建excel文件。通过使用DataImportProperties.UseColumnNames=true,列标题是用类属性名称填充的,但是我想给出定制的列标题。有什么建议吗?
发布于 2015-07-08 15:03:42
Donot use DataImportProperties.UseColumnNames=true.Instead use cell specific formatting since it is header so for every cell row/column number is known.ex.
Style headerStyle = wb.CreateStyle();
headerStyle.Font.Size = 10;
headerStyle.Font.Bold = true;
ws.Cells[1, 0].Value = "Name";
ws.Cells[1, 0].ApplyStyle(headerStyle);
You can also merge and group columns as :
ws[0, 0].Value = "Information";
Palette pal = wb.Palette;
Color group1Color = pal.GetClosestColor(255, 244, 205);
headerStyle.BackgroundColor = group1Color;
headerStyle.Font.Bold = true;
ws[0, 0].ApplyStyle(headerStyle);
ws.CreateArea(0, 0, 1, 13).MergeCells();
ws.GroupColumns(0, 12, true);
//True/false keeps the group collapsed/uncollpasedwhen user opens the workbook.https://stackoverflow.com/questions/31269364
复制相似问题