Spreadsheetgear not loading

☆樱花仙子☆ 提交于 2019-12-22 01:08:46

问题


I receive this error whenever I reach the part of the code that generates an excel table.

Unable to load SpreadsheetGear2012.Drawing.dll or SpreadsheetGear2012.Windows.WPF.dll which contain graphics capabilities.

I tried uninstalling and reinstalling SpreadsheetGear; removing the assembly and bringing it back but the problem still persists.

I'm using spreadsheetgear with c#.


回答1:


One common reason this exception can occur is if you have multiple VS Projects that utilize SpreadsheetGear directly and indirectly, such as the following:

  • Project A – utilizes SpreadsheetGear directly
  • Project B – utilizes Project A but not SpreadsheetGear directly

In such a case you would still need to add a reference to one of the graphics assemblies (SpreadsheetGear2012.Drawing.dll or SpreadsheetGear2012.WPF.dll) in Project B because the "Core" dynamically attempts to load an available graphics assembly at runtime and Visual Studio won't always copy over all the necessary SpreadsheetGear assemblies into Project B's bin folder. You might also ensure that the "Copy Local" option in the Properties panel for all of our assemblies is set to true, and that they all match as far as version number.

Often times the "Core" needs to access a graphics assembly to do some sort of text-measuring type of work, even if the task you are performing on the workbook does not involve a UI. For instance, calling AutoFit() on a range of cells would trigger a call into one of our graphics assemblies to measure text and fit the column(s) accordingly. Just the act of saving a workbook could also trigger a call into a graphics assembly if the file being saved contains shapes, which rely on row/column offsets for their positioning, which in turn rely on "Character Units" that are measured using the default font for the workbook.

You can read more about SpreadsheetGear's various assembly files at: http://www.spreadsheetgear.com/support/help/spreadsheetgear.net.7.0/#Key_Concept_SpreadsheetGear_Assemblies.html




回答2:


I ran into a similar issue today. Below is the exception I got.

Unable to load SpreadsheetGear2012.Drawing.dll or SpreadsheetGear2012.Windows.WPF.dll which contain graphics capabilities needed for the current operation.
Add a reference to one of these to your project.
If you still get this exception (common in libraries) try adding a dummy reference such as "internal static SpreadsheetGear.Drawing.Color _dummyReference;" for SpreadsheetGear2012.Drawing.dll or "internal static SpreadsheetGear.Windows.Media.Image _dummyReference = null;" for SpreadsheetGear2012.Windows.WPF.dll.

I resolved the issue by adding a dummy refrence as shown in the exception.

internal static SpreadsheetGear.Drawing.Color _dummyReference;

Hope this helps in some way.




回答3:


The Problem might be with the excel sheet.

i ran into the same problem and solved it by opening the excel and searching for any charts/images or other stuff related to drawing.

I wanted to get a Datatable for a specific range but few charts and images were in between . so i removed them and ran the code. it worked. Or you can reference drawing.dll if you have. Dont know whether its free or paid.



来源:https://stackoverflow.com/questions/38417821/spreadsheetgear-not-loading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!