This project has moved and is read-only. For the latest updates, please go here.

Read an xlsx file

Jun 24, 2014 at 4:00 PM
Hi,

I can't read an xlsx file, i use this following code :
FileInfo fileInfo = new FileInfo(xlsxFile);
ExcelPackage package = new ExcelPackage(fileInfo);
IEnumerable<string> list = package.Workbook.Worksheets.Select(w => w.Name);
and I have systematically this exception with some files xlsx.
___URI non valide : Impossible d'analyser le nom d'hôte.___
à System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
à System.Uri..ctor(String uriString, UriKind uriKind)
à MS.Internal.IO.Packaging.InternalRelationshipCollection.ProcessRelationshipAttributes(XmlCompatibilityReader reader)
   à MS.Internal.IO.Packaging.InternalRelationshipCollection.ParseRelationshipPart(PackagePart part)
   à MS.Internal.IO.Packaging.InternalRelationshipCollection..ctor(Package package, PackagePart part)
   à System.IO.Packaging.PackagePart.EnsureRelationships()
   à System.IO.Packaging.PackagePart.GetRelationshipHelper(String id)
   à System.IO.Packaging.PackagePart.GetRelationship(String id)
   à OfficeOpenXml.ExcelWorksheet.LoadHyperLinks(XmlTextReader xr)
   à OfficeOpenXml.ExcelWorksheet.CreateXml()
   à OfficeOpenXml.ExcelWorksheet..ctor(XmlNamespaceManager ns, ExcelPackage excelPackage, String relID, Uri uriWorksheet, String sheetName, Int32 sheetID, Int32 positionID, eWorkSheetHidden hide)
   à OfficeOpenXml.ExcelWorksheets..ctor(ExcelPackage pck, XmlNamespaceManager nsm, XmlNode topNode)
   à OfficeOpenXml.ExcelWorkbook.get_Worksheets()
   à OfficeOpenXml.ExcelWorkbook.GetDefinedNames()
   à OfficeOpenXml.ExcelPackage.get_Workbook()
Any idea to solve this ?

Regards