使用Spire组件抛出异常The type initializer for 'spr857' threw an exception
2015-03-23 16:53
281 查看
使用Spire组件抛出异常The type initializer for 'spr857' threw an exception
我使用免费的Spire.Xls组件尝试去转换Excel文档到PDF文档,在执行下面第二行代码,也就是做加载文档这步时,抛出了异常“The type initializer for 'spr857' threw
an exception”
Workbook workbook = new Workbook();
workbook.LoadFromFile("D:\\sample.xlsx");
workbook.SaveToFile("D:\\sample.pdf", Spire.Xls.FileFormat.PDF);
这个问题困扰了我老半天,在网上也没搜到它的解决方案,后来访问了E-iceblue公司的论坛,才找到了它的解决方案,E-iceblue 公司的技术人员回复的说是:please make sure Spire.pdf.dll file is placed in the same location as
Spire.xls.dll.
根据这个意思我尝试了两种方案,都能解决这个问题,在这里分享一下:
方案1,将Spire.Xls包里的Spire.pdf.dll文件拷贝到Spire.Xls.dll相同的目录下。
方案2,将Spire.XLS.dll和Spire.Pdf.dll同时作为Reference导入到项目里。
转换出来的结果真是完美极了:
原始的Excel:
转换出来的PDF:
在使用Spire.Xls的同时,我也在尝试使用免费的Spire.Doc去做Word文档到PDF文档转换时,遇到了相同的问题,上面的两个方案也适用在Spire.Doc组件中。
我使用免费的Spire.Xls组件尝试去转换Excel文档到PDF文档,在执行下面第二行代码,也就是做加载文档这步时,抛出了异常“The type initializer for 'spr857' threw
an exception”
Workbook workbook = new Workbook();
workbook.LoadFromFile("D:\\sample.xlsx");
workbook.SaveToFile("D:\\sample.pdf", Spire.Xls.FileFormat.PDF);
这个问题困扰了我老半天,在网上也没搜到它的解决方案,后来访问了E-iceblue公司的论坛,才找到了它的解决方案,E-iceblue 公司的技术人员回复的说是:please make sure Spire.pdf.dll file is placed in the same location as
Spire.xls.dll.
根据这个意思我尝试了两种方案,都能解决这个问题,在这里分享一下:
方案1,将Spire.Xls包里的Spire.pdf.dll文件拷贝到Spire.Xls.dll相同的目录下。
方案2,将Spire.XLS.dll和Spire.Pdf.dll同时作为Reference导入到项目里。
转换出来的结果真是完美极了:
原始的Excel:
转换出来的PDF:
在使用Spire.Xls的同时,我也在尝试使用免费的Spire.Doc去做Word文档到PDF文档转换时,遇到了相同的问题,上面的两个方案也适用在Spire.Doc组件中。
相关文章推荐
- 使用Spire组件抛出异常The type initializer for 'spr857' threw an exception
- 使用Spire组件抛出异常The type initializer for 'spr857' threw an exception
- Servlet.service() for servlet jsp threw exception java.lang.Il在jsp中使用jspsmartupload组件下载文件时将抛出异常的解决方案
- RegAsm注册DLL组件使用jacob调用的问题com.jacob.com.ComFailException: Can't co-create object
- atmel studio 6.0使用jlink下载报错、failed to launch program Error: the service threw an unknow exception
- 【异常】SparkStreaming抛出Listener SQLListener threw an exception异常
- SqlConnection new 的時候,报:“The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.”
- 'Provide value on 'System.Windows.StaticResourceExtension' threw an exception.'
- 'Set property 'System.Windows.ResourceDictionary.DeferrableContent' threw an exception.
- The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.
- 解决Set property 'System.Windows.ResourceDictionary.DeferrableContent'threw an exception.
- What Can I do if "The type initializer for 'Emgu.CV.CvInvoke' threw an exception"?
- SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 s
- NUnit Error: The Type Initializer for … Threw an Exception (And app.config)
- SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用
- 使用Axis2报"An error occurred while completing process -java.lang.reflect.InvocationTargetException"处理
- PHPExcel的exception 'Exception' with message 'The filename is not recognised as an OLE file问题解决
- Eclipse使用axis2生成客户端调用时最后一步出现an error occurred while completing process -java.lang.reflect.InvocationTargetException
- 在 Visual Studio 单元测试中使用CallContext 导致的 Unit Test Adapter threw exception: Type is not resolved for member... 异常
- javax.servlet.ServletException: Servlet execution threw an exception