System.IO.IOException using flexgrid.savegrid to xlsx

Posted by: tom.galczynski on 5 August 2021, 1:57 pm EST

  • Posted 5 August 2021, 1:57 pm EST

    Hello. In our WinForms app we are using C1FlexGrid.SaveGrid to enable our users to save the grid to an Excel xlsx file. We use this syntax:

    Me._queryResultsGrid.SaveGrid(saveWindow.FileName, C1.Win.C1FlexGrid.FileFormatEnum.Excel, C1.Win.C1FlexGrid.FileFlags.VisibleOnly Or C1.Win.C1FlexGrid.FileFlags.IncludeFixedCells Or C1.Win.C1FlexGrid.FileFlags.AsDisplayed Or C1.Win.C1FlexGrid.FileFlags.IncludeMergedRanges Or C1.Win.C1FlexGrid.FileFlags.LoadMergedRanges Or C1.Win.C1FlexGrid.FileFlags.OpenXml)

    One user runs into this error when they try to use this function from our app:

    System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open.

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

    at System.IO.FileStream.SetLengthCore(Int64 value)

    at C1.C1Zip.d.a()

    at C1.C1Zip.d.c()

    at C1.C1Zip.C1ZipFile.a(Stream A_0, String A_1, DateTime A_2)

    at C1.C1Zip.C1ZipEntryCollection.Add(Stream stream, String entryName)

    at C1.C1Excel.aq.a(C1ZipFile A_0)

    at C1.C1Excel.aq.c(String A_0)

    at C1.C1Excel.C1XLBook.a(String A_0)

    at C1.Win.C1FlexGrid.Exporter.SaveGridExcel(String fileName, String sheetName, FileFlags flags, PrinterSettings ps)

    at C1.Win.C1FlexGrid.Exporter.SaveGrid(String fileName, FileFormatEnum fileFormat, FileFlags flags, Encoding encoding)

    at C1.Win.C1FlexGrid.Extensions.SaveGrid(C1FlexGridBase grid, String fileName, FileFormatEnum format, FileFlags flags)

    at ProductVision.Windows.Forms.FormQuery.ToolStripQueryResults_SaveAs_Click(Object sender, EventArgs e) in C:\VS2015\ProductVision 5.2\Build 5.2.1005.15\ProductVision 5.0\PVClient\ProductVision.Windows.Forms\ApplicationForms\FormQuery.vb:line 14964

    It doesn’t matter if they select an existing file to overwrite or setup a new file name, the error is the same. No other user gets this error, and we cannot reproduce it. From the error message, can you give us some indication of what might be the problem for this user? Something apparently has the output file locked but we cannot figure out why that would happen for this one user.

    Thanks!

    Tom G.

  • Posted 6 August 2021, 2:20 am EST

    Hi,

    This exception occurs when the file is open, probably elsewhere in your own app or some other app, and cannot be opened by the external process to edit the file until it is closed. Please make sure that no other app or process is accessing the files that you are trying to save.

    Also, could you please let us know the version of C1 you are using?

    Regards

    Avnish

  • Posted 6 August 2021, 8:14 am EST

    It’s strange because the file doesn’t exist when we call SaveGrid and the user still gets the error. The C1 version is 4.0.20183.343. Thank you.

  • Posted 9 August 2021, 5:09 am EST

    Hi,

    Could you please let us know at what location are you trying to save the file. Do you have the permissions to save at the location or is it a shared location. Also could you please share the environment details of the system where you are facing this issue.

    The version you are using is very old. NET4.0 controls have been in maintenance mode for a long time and We would suggest you please check with the latest NET4.5.2 version and see if the issue persists.

    Regards

    Avnish

  • Posted 9 August 2021, 10:09 am EST

    We are told by the user he has admin rights to “everywhere”, and he is on the latest Windows version. Just learned he does NOT get the error when saving the Excel to an “xls” file, just “xlsx”. From your explanation that the error means the file is open, I suspect some anti-virus app is grabbing the file as soon as it gets created or something external to our app is involved somehow. Thanks for your help.

  • Posted 10 August 2021, 3:50 am EST

    Hi,

    Since the issue is happening only at one of your users end and it is not replicable at our end. It is most likely that the issue is due to some configuration at the user’s end.

    If you need any other help, please let us know.

    Regards

    Avnish

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels