Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Critical bug when writing and reading again #37

Closed
omaus opened this issue Jul 19, 2023 · 2 comments
Closed

[BUG] Critical bug when writing and reading again #37

omaus opened this issue Jul 19, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@omaus
Copy link
Collaborator

omaus commented Jul 19, 2023

Describe the bug
When writing a spreadsheet file and reading it again, it throws an error regardless of what has been done to the structure/file.

To Reproduce
Steps to reproduce the behavior:

  1. Do this:
#r "nuget: FsSpreadsheet"
#r "nuget: FsSpreadsheet.ExcelIO"

open FsSpreadsheet
open FsSpreadsheet.ExcelIO

let path = <yourPath>

let wb = new FsWorkbook()

wb.InitWorksheet "empty"

FsWorkbook.toFile path wb

let wbFromFile = FsWorkbook.fromXlsxFile path
  1. See error:
System.IO.IOException: Cannot modify readonly container
   at System.IO.Packaging.Package.ThrowIfReadOnly()
   at System.IO.Packaging.Package.CreatePart(Uri partUri, String contentType, CompressionOption compressionOption)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.CreateMetroPart(Uri partUri, String contentType)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPart.CreateInternal(OpenXmlPackage openXmlPackage, OpenXmlPart parent, String contentType, String targetExt)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.InitPart[T](T newPart, String contentType, String id)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.InitPart[T](T newPart, String contentType)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddNewPartInternal[T]()
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.AddNewPart[T]()
   at FsSpreadsheet.ExcelIO.Spreadsheet.getOrInitSharedStringTablePart(SpreadsheetDocument spreadsheetDocument)
   at FsSpreadsheet.ExcelIO.Spreadsheet.getCellsBySheet(Sheet sheet, SpreadsheetDocument spreadsheetDocument)
   at FsSpreadsheet.ExcelIO.Spreadsheet.getCellsBySheetID(String sheetID, SpreadsheetDocument spreadsheetDocument)
   at FsSpreadsheet.ExcelIO.FsExtensions.sheets@182.Invoke(Sheet xlsxSheet)
   at Microsoft.FSharp.Collections.Internal.IEnumerator.map@128.DoMoveNext(b& curr) in D:\a\_work\1\s\src\FSharp.Core\seq.fs:line 134
   at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System.Collections.IEnumerator.MoveNext() in D:\a\_work\1\s\src\FSharp.Core\seq.fs:line 117
   at Microsoft.FSharp.Collections.SeqModule.Fold[T,TState](FSharpFunc`2 folder, TState state, IEnumerable`1 source) in D:\a\_work\1\s\src\FSharp.Core\seq.fs:line 914
   at FsSpreadsheet.ExcelIO.FsExtensions.FsWorkbook.fromXlsxFile.Static(String filePath)
   at <StartupCode$FSI_0006>.$FSI_0006.main@() in C:\Users\olive\Untitled-2:line 15
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
Stopped due to error

Expected behavior
Reading should work as expected.

Additional context
It seems to be an error produced by the writer, not the reader. When reading files that were created by Excel, no error happens.

@omaus omaus added the bug Something isn't working label Jul 19, 2023
@HLWeil
Copy link
Member

HLWeil commented Jul 19, 2023

Currently working on it

@HLWeil
Copy link
Member

HLWeil commented Jul 19, 2023

fixed in #40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants