asp.net导出Excel,如何改变单元格中的字体
stringBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
stringBuilder.Append("<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\n");
stringBuilder.Append("xmlns:x=\"urn:schemas-microsoft-com:office:excel\"\n");
stringBuilder.Append("xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"\n");
stringBuilder.Append("xmlns:html=\"http://www.w3.org/TR/REC-html40\">\n");
stringBuilder.Append("<Worksheet ss:Name=\"Table1\">\n");
stringBuilder.Append("<Table>\n");
stringBuilder.Append("<Column ss:Index=\"1\" ss:AutoFitWidth=\"0\" ss:Width=\"110\"/>\n");
stringBuilder.Append("<Row>\n");
stringBuilder.Append("<Cell><Data ss:Type=\"String\">订单号</Data></Cell>\n");
stringBuilder.Append("</Row>\n");
下面的代码需要设置输出字体的颜色
stringBuilder.Append("<Row>\n");
stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].Tid + "</Data></Cell>\n");
stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].BuyerNick + "</Data></Cell>\n");
stringBuilder.Append("</Row>\n");
ASP.NET
Excel
String
Office
spreadsheet
------解决方案--------------------百度搜索 myxls
可以修改字体 大小 以及多sheet合并单元格等操作
------解决方案-------------------- <Style ss:ID="s22">
<Interior ss:Color="#FFFF00" ss:Pattern="Solid"/>
</Style>
<Row>
<Cell ss:StyleID="s21"><Data ss:Type="String">A</Data></Cell>
<Cell
ss:StyleID="s22"><Data ss:Type="String">B</Data></Cell>
</Row>
------解决方案--------------------试一试这样:
<Styles>
<Style ss:ID="s22">
<Interior ss:Color="#FFFF00" ss:Pattern="Solid"/>
</Style>
</Styles>
<table>
<Row>
<Cell ss:StyleID="s22"><Data ss:Type="String">B</Data></Cell>
</Row>
</table>
------解决方案--------------------