EPPlus抛出DataValidations异常未找到“请求值”日期。当尝试保存xlsm [英] EPPlus throws DataValidations exception "Requested value 'date' was not found." when trying to save xlsm
问题描述
我正在尝试更改客户提供的 .xlsm 文件(C#应用程序将填写网络表单中的数据并提交给CMS)使用 EPPlus。
I'm attempting to make changes to a customer-supplied .xlsm file (a C# application will fill with data from a web-form and submit to a CMS) using EPPlus.
但是在package.Save(name) - 或packagae .SaveAs(name) - DataValidations集合抛出异常:
But on package.Save(name) -- or packagae.SaveAs(name) -- an exception is thrown by the DataValidations collection:
2011-11-28 14:17:51,380 [9] ERROR app.ExcelConverter - System.ArgumentException: Requested value 'date' was not found.
at System.Enum.EnumResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument)
at System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, EnumResult& parseResult)
at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
at OfficeOpenXml.DataValidation.ExcelDataValidationCollection..ctor(ExcelWorksheet worksheet)
at OfficeOpenXml.ExcelWorksheet.get_DataValidations()
at FItoExcelCore.ExcelConverter.RunSample(String filePath) in \path\to\class.cs:line 32
即使尝试使用worksheet.DataValidations.Clear()抛出同样的异常,对文件也没有任何变化:
Even attempting worksheet.DataValidations.Clear() throws the same exception, and this is without any changes to the file:
try
{
using (ExcelPackage package = new ExcelPackage(output))
{
package.SaveAs(output);
}
}
catch (Exception ex)
{
_log.Error(ex.ToString());
}
我从头开始创建的excel文件中没有这个行为,但是我需要使用提供的文件。
I do not have this behavior in an excel file that I create from scratch, but I need to use the supplied file.
不知道它是否重要,但是我在.Net 4框架中工作,它是一个1.01 MB。 xlsm文件。文件保存/保存(甚至使用新的数据)从Excel内。
Don't know if it's significant, but I'm working in the .Net 4 Framework, and it's an 1.01 MB .xlsm file. The file saves/saves-as fine (even with new data) from within Excel.
注意:显然 .xlsx 文件工作正常,但是.xlsm格式包含不能以.xlsx格式保存的VBA宏,因此无法转换文件类型。
NOTE: apparently .xlsx files work just fine, but the the .xlsm format contain VBA macros that can't be saved in the .xlsx format, so the file-type cannot be converted.
推荐答案
像往常一样,在发布后的六十秒内,我在网上找到新的信息。
As usual, within sixty seconds of posting I find new information online.
有一个讨论在EPPlus codeplex网站,表明没有真正的支持组件中的[xlsm文件]。
There is a discussion at the EPPlus codeplex site that suggests that "there is no real support for [xlsm files] in the component."
可能是问题的根源。
这篇关于EPPlus抛出DataValidations异常未找到“请求值”日期。当尝试保存xlsm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!