转自:http://www.cnblogs.com/juqiang/archive/2004/07/08/22255.html
类下载地址 :
https://files.cnblogs.com/unruledboy/smartexcel.rar
测试代码:
![](/Images/OutliningIndicators/ContractedBlock.gif)
测试代码
1
private void button1_Click(object sender, System.EventArgs e)
2![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
3
SmartExcel excel = new SmartExcel();
4
excel.CreateFile("c:\\test.xls");
5
excel.PrintGridLines = false;
6![](/Images/OutliningIndicators/InBlock.gif)
7
double height = 1.5;
8![](/Images/OutliningIndicators/InBlock.gif)
9
excel.SetMargin(MarginTypes.TopMargin, height);
10
excel.SetMargin(MarginTypes.BottomMargin, height);
11
excel.SetMargin(MarginTypes.LeftMargin, height);
12
excel.SetMargin(MarginTypes.RightMargin, height);
13![](/Images/OutliningIndicators/InBlock.gif)
14
string font = "Arial";
15
short fontsize = 12;
16
excel.SetFont(font,fontsize,FontFormatting.Italic);
17![](/Images/OutliningIndicators/InBlock.gif)
18
byte b1 = 1,b2 = 12;
19
short s3 = 18;
20
excel.SetColumnWidth(b1,b2,s3);
21![](/Images/OutliningIndicators/InBlock.gif)
22
string header = "头";
23
string footer = "角";
24
excel.SetHeader(header);
25
excel .SetFooter(footer);
26![](/Images/OutliningIndicators/InBlock.gif)
27
int row = 1,col = 1,cellformat = 0;
28
object title = "没有使用任何EXCEL组件,直接写成了一个EXCEL文件,cool吧?!";
29
excel.WriteValue(ValueTypes.Text,CellFont.Font0,CellAlignment.LeftAlign,CellHiddenLocked.Normal,row,col,title,cellformat);
30![](/Images/OutliningIndicators/InBlock.gif)
31
excel.CloseFile();
32
}
33![](/Images/OutliningIndicators/None.gif)
非常感谢灵感大哥写的代码,还有
juqiang辛苦的翻译。