Skip to content

Method not found: 'System.IO.MemoryStream Microsoft.IO.RecyclableMemoryStreamManager.GetStream() #1

@Clive321A

Description

@Clive321A

Hi, was having a initial look at this package, but when executing the sample code (.net 8)
An exception is throw on new ExcelPackage()

Method not found: 'System.IO.MemoryStream Microsoft.IO.RecyclableMemoryStreamManager.GetStream()
 using (var excelFile = new ExcelPackage())
 {
     ExcelReport.BuildReport(loader.Records, loader.Workouts, excelFile.Workbook, Settings.Default,NodaTime.DateTimeZone.Utc, customSheets: Enumerable.Empty<ExcelWorksheet>());

     excelFile.SaveAs(new FileInfo(@"c:\temp\output.xlsx"));
 }

Also in the sample, it has a Using( I could not get to compile,

I ended up doing it like this, which I think achieves the same result, apart from the Exception above


using (var streamReader = new StreamReader(@"c:\temp\export.zip"))
{
   var loader = ZipUtilities.ReadArchive(
       streamReader.BaseStream,
       entry => entry.FullName == "apple_health_export/export.xml",
       entry => new XmlReaderExportLoader(entry.Open()))
   .FirstOrDefault();

   if (loader != null)
   {
       using (var excelFile = new ExcelPackage())
       {
           ExcelReport.BuildReport(loader.Records, loader.Workouts, excelFile.Workbook, Settings.Default,NodaTime.DateTimeZone.Utc, customSheets: Enumerable.Empty<ExcelWorksheet>());

           excelFile.SaveAs(new FileInfo(@"c:\temp\output.xlsx"));
       }
   }
   else
   {
       // Handle case where no loader was found
       Console.WriteLine("No loader found.");
   }
}

In .net 8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions