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