GemBox.ExcelLite "完美"的导入Excel的控件
下载了这个控件,简单测试了下到处Excel。以下是我测试的代码:
![ContractedBlock.gif](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
1
ExcelFile excelFile
=
new
ExcelFile();
2 ExcelWorksheet sheet = excelFile.Worksheets.Add( " WolfSpider " );
3
4 for ( int j = 0 ; j < 100 ; j ++ )
5 {
6 sheet.Cells[ 0 , j].Value = " 头 " + j;
7 sheet.Cells[ 0 , j].Style.Font.Size = 400 ;
8 sheet.Cells[ 0 , j].SetBorders(MultipleBorders.All, System.Drawing.Color.Red, LineStyle.Hair);
9 }
10
11 for ( int i = 1 ; i <= 10000 ; i ++ )
12 {
13 for ( int j = 0 ; j < 100 ; j ++ )
14 {
15 sheet1.Cells[i, j].Value = " 数据 " + i + " , " + j;
16 }
17 }
18 excelFile.SaveXls( " C:\\xinde.xls " ); // 这里的文件名可以任意定义
2 ExcelWorksheet sheet = excelFile.Worksheets.Add( " WolfSpider " );
3
4 for ( int j = 0 ; j < 100 ; j ++ )
5 {
6 sheet.Cells[ 0 , j].Value = " 头 " + j;
7 sheet.Cells[ 0 , j].Style.Font.Size = 400 ;
8 sheet.Cells[ 0 , j].SetBorders(MultipleBorders.All, System.Drawing.Color.Red, LineStyle.Hair);
9 }
10
11 for ( int i = 1 ; i <= 10000 ; i ++ )
12 {
13 for ( int j = 0 ; j < 100 ; j ++ )
14 {
15 sheet1.Cells[i, j].Value = " 数据 " + i + " , " + j;
16 }
17 }
18 excelFile.SaveXls( " C:\\xinde.xls " ); // 这里的文件名可以任意定义
感觉起来,这个控件的使用还是挺简单的。
可以设置每格的样式,还有可以自定义sheet的数量与名字。
不过不知道是不是我没有发现还是本身缺少,在控件中没有发现直接传数据集然后生成Excel的类或者方法。
还有就是,使用这个空间很容易造成数据溢出。
比如不设置样式的话,100*30000 就会造成溢出,如果每格都设置样式的话,100*10000都不行。
总结:
优点:速度快,(100*10000的数据可以在22秒左右完成)
灵活,可以自定义sheet的数量与名字,还可以设计表头与内容的样式。
缺点:没有直接传数据集生成Excel的方法或者类。
容易造成内存溢出。
GemBox.ExcelLite "完美"的导入Excel的控件(补充)