2016-08-18 108 views
0

我通过EPPlus创建了两个工作表的excel文件:数据和数据图表。 Excel可以无任何错误地打开文件。Excel打开由EPPlus创建的文件,出现错误

现在,我读取(通过EPPlus),并再次保存该文件而不做任何更改,并且Excel打开带错误消息的文件并且不显示图表。

enter image description here enter image description here xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>error118920_01.xml</logFileName><summary>Errors were detected in file 'file.xlsx'</summary><removedParts summary="Following is a list of removed parts:"><removedPart>Removed Part: /xl/drawings/drawing1.xml part. (Drawing shape)</removedPart></removedParts></recoveryLog>

+0

这些错误是非常通用的,所以不会很遗憾地告诉我们。最好的做法是粘贴创建它的代码,然后重新打开/保存它。 – Ernie

+0

创建示例https://github.com/constructor-igor/TechSugar/tree/master/EPPlusSamples,但我无法通过示例重现问题。现在,我无法发布产品代码, – constructor

+0

难以诊断它是否不可重现。也许发布问题文件? – Ernie

回答

0

对不起这么晚了答案。似乎Excel文件在图表x轴中有一个不好的参考。如果你去选择图表中的数据,并击中了分类轴标签右侧的修改,你会看到:

enter image description here

但是='Charts'!看起来像一个破碎的参考。似乎Epplus无法很好地处理 - 可能应该将其记录为一个错误。所以,要解决这个问题,请点击图表x轴并点击删除。应该是这样的后:

enter image description here

保存文件并运行它,虽然你的单元测试,它正确地打开了我。

Ernie

+0

我通过下一个代码串定义的系列yName =的String.Format(ProductionFile_OpenSave_CannotBeOpened” '“+ dataWorkSheet.Name +”'“+”!{0} 2:{0} {1}“,columnName,rowsCount); var excelChartSerie = chart.Series.Add(yName,“”); – constructor

相关问题