分享个c#的excel, pdf,word,PowerPoint第三方Syncfusion操作程序集DocIO/xlsIO...

By admin at 2023-01-12 • 0人收藏 • 952人看过

image.png

File Format libraryDescription
Essential PDF.NET Class library used to create, read, and write PDF files in .NET Framework [Windows Forms, WPF, ASP.NET MVC, ASP.NET], .NET Core, UWP and Xamarin applications.
Essential XlsIO.NET Class library used to create, read, edit, write, and convert Microsoft Excel files in .NET Framework [Windows Forms, WPF, ASP.NET MVC, ASP.NET], .NET Core, UWP, and Xamarin applications.
Essential DocIO.NET Class library used to create, read, edit, and convert Microsoft Word files in .NET Framework [Windows Forms, WPF, ASP.NET MVC, ASP.NET], .NET Core, UWP, and Xamarin applications.
Essential Presentation.NET Class library used to create, read, edit, and convert Microsoft PowerPoint (PPTX) files in .NET Framework [Windows Forms, WPF, ASP.NET MVC, ASP.NET], .NET Core, UWP, and Xamarin applications.

Create a PDF file in C# without Adobe
Create Excel file in C# without Microsoft Office
Create Word file in C# without Microsoft Office
Create PowerPoint file in C# without Microsoft Office


官方地址: 

https://help.syncfusion.com/file-formats/introduction#list-of-file-format-libraries


试用版生成文档会有试用提示.


using Syncfusion.XlsIO;
ExcelEngine excelEngine = new ExcelEngine();

//Instantiate the Excel application object
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);

//Access a worksheet from workbook
IWorksheet worksheet = workbook.Worksheets[0];

worksheet.Range[行, 列].Number = pA;
//worksheet.Range["A3"].Number = pA;

//Saving the workbook to disk in XLSX format
workbook.SaveAs("SampleTest_"+ DateTime.Now.ToString("yyMMddhhmmss") + ".xlsx");
//Closing the workbook
workbook.Close();
//Dispose the Excel engine
excelEngine.Dispose();

image.png

8 个回复 | 最后更新于 2023-01-16
2023-01-13   #1

xlsIO 20.3.0.47 的注册版, 可以体验正版的功能了.


链接:https://pan.baidu.com/s/1LzVAogRdL8T3iJ6r7BKADA?pwd=zaku

提取码:zaku


Syncfusion的所有可用程序集,所有的Dll集合


注册Key如下:

MDAxQDMyMzAyRTMzMkUzMFlMdDQ3dXd2M0crb3ZhYi93RjBBaUpESEhwUE1kT05ReW1WcWE3a2ErVUE9



链接:https://pan.baidu.com/s/1qI-UfLSkQNJUnoYWQPEPDA?pwd=8k8h

 

提取码:8k8h



下面介绍下怎么用:

vs引用了里引用 Syncfusion.XlsIO.Base.dll  和 Syncfusion.Licensing.dll

在工程的program.cs里注册:

//Register Syncfusion license
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MDAxQDMyMzAyRTMzMkUzMFlMdDQ3dXd2M0crb3ZhYi93RjBBaUpESEhwUE1kT05ReW1WcWE3a2ErVUE9");

image.png



2023-01-13   #2

最喜欢各种office 的帖子。

2023-01-13   #3

哈哈哈哈....

2023-01-15   #4

其实操作excel还是用python方便,现在aardio调用python也比以往更容易了。

import console;
console.setTitle("python_openpyxl");

console.open();

import py3.10;
py3.appendPath("\py");

openpyxl = py3.import("openpyxl");
wb = openpyxl.Workbook();
wb.create_sheet("Sheet1", index=0);
ws = wb.worksheets[0];
ws.append({"col1", "col2"});
ws.append({1,2});
wb.save("test.xlsx");
wb.close();


/** //直接用python代码
pycode = `
import openpyxl as xl
wb = xl.Workbook()
wb.create_sheet("Sheet1", index=0)
ws = wb.worksheets[0]
ws.append(["col1", "col2"])
ws.append([1,2])
wb.save('C:\\Users\\Administrator\\Desktop\\test.xlsx')
wb.close()

`

py3.exec(pycode);
**/

console.pause();

注:

需要在py目录下把依赖库(openpyxl和et_xmlfile)复制进去。

2023-01-15   #5

读取也没问题

openpyxl = py3.import("openpyxl");
wb = openpyxl.load_workbook("C:\\Users\\Administrator\\Desktop\\test.xlsx");
ws = wb.worksheets[0];
console.log(ws.cell(1,1).value)


2023-01-16   #6

openpyxl 有个问题,在向已有的合并单元格中填充内容时,单元格的框会变化,整的好好看的,一填充,不顺眼了。。。

直接利用c# 处理excel这种还没遇到过类似问题。


还有python这个依赖,那个依赖,有时候头疼。。

2023-01-16   #7

回复#4 @jerrxjr1220 :

这种方式也确实狠....

谢谢指导


预祝jerrxjr1220,admin新年身体健康!

2023-01-16   #8

回复#7 @hi_aardio :

openpyxl效率也还不错,10000行循环写入大约500毫秒,100000行循环写入6秒。

读取的速度比写入快1倍。


然后整体打包的话,不压缩14M,压缩后9M。


体积大主要是因为把python3.10打包进去了,openpyxl体积其实很小的,也完全可以脱离office读写excel。


新年快乐!


登录后方可回帖

登 录
信息栏
 私人小站

本站域名

ChengXu.XYZ

投诉联系:  popdes@126.com



快速上位机开发学习,本站主要记录了学习过程中遇到的问题和解决办法及上位机代码分享

这里主要专注于学习交流和经验分享.
纯私人站,当笔记本用的,学到哪写到哪.
如果侵权,联系 Popdes@126.com

友情链接
Aardio官方
Aardio资源网


才仁机械


网站地图SiteMap

Loading...