EPPlus lance DataValidations exception « valeur demandée « date » n'a pas été trouvé. » en essayant de sauver xlsm

StackOverflow https://stackoverflow.com/questions/8302801

Question

Je tente d'apporter des modifications à un client fourni .xlsm fichier (une application C # remplira les données d'un formulaire web et soumettre à un CMS) en utilisant EPPlus.

Mais package.Save (nom) - ou packagae.SaveAs (nom) - une exception est levée par la collection DataValidations:

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

Même tente worksheet.DataValidations.Clear () renvoie la même exception, et cela est sans aucune modification du fichier:

        try
        {
            using (ExcelPackage package = new ExcelPackage(output))
            {
                package.SaveAs(output);
            }
        }
        catch (Exception ex)
        {
            _log.Error(ex.ToString());
        }

Je n'ai pas ce comportement dans un fichier Excel que je crée à partir de zéro, mais je dois utiliser le fichier fourni.

Je ne sais pas si elle est importante, mais je travaille dans le Framework 4, et il est un fichier .xlsm 1.01 MB. Le fichier sauvegarde / sauvegarde-aussi fine (même avec de nouvelles données) à partir d'Excel.

NOTE: apparemment .xlsx les fichiers fonctionnent très bien, mais le format .xlsm contiennent des macros VBA qui ne peuvent pas être enregistrés dans le format .xlsx, de sorte que le type de fichier ne peut pas être converti.

Était-ce utile?

La solution

As usual, within sixty seconds of posting I find new information online.

There is a discussion at the EPPlus codeplex site that suggests that "there is no real support for [xlsm files] in the component."

The may be the source of the problem.

Autres conseils

Do you have the latest version of EPPlus?

They fixed this issue March of 2011. It had to do with ValidationTypes being case insensitive.

See: http://epplus.codeplex.com/workitem/13246

Edit: You can also try saving it as .xlsx if xlsm isn't supported.

As Ed Wrote i have donwloaded the last version of EPPlus which is from Jan 31 2012,and it worked very well with its validation. The excel im reading and writting is a .xlsx format.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top