How to Excel Import / Export

Posted by: soraroid on 11 November 2024, 4:11 am EST

    • Post Options:
    • Link

    Posted 11 November 2024, 4:11 am EST

    Hello.

    I’m currently creating a program using the web assembly method.

    I would like to download the contents of the grid as an Excel file(.xlsx) using the original file(.xlsx) format on the server.

    I would also like to know how to import data from a specific Excel file uploaded by the user into the grid.

    Please answer with example source.

    Thank you.

  • Posted 12 November 2024, 5:19 am EST - Updated 12 November 2024, 5:24 am EST

    Hi,

    By default, the FlexGrid doesn’t provide any API for importing the Excel file as the format and the type of the Excel file being used is not known.

    For Exporting, you could refer to the following demo: https://developer.mescius.com/componentone/demos/blazor/blazorexplorer/FlexGrid/ExportExcel

    You could also refer to the following Docs: https://developer.mescius.com/componentone/docs/blazor/online-blazor/exporting_data.html

    Further, if you could also use the C1Excel to import/export the Excel file. Refer to the following demo on Excel export from FlexGrid using the C1Excel: https://developer.mescius.com/componentone/demos/blazor/blazorexplorer/Excel/Export

    For importing the Excel file, I have also used the C1Excel, read the first sheet, and typecast to the corresponding class and then load the data to the grid.

    Please refer to the attached sample that demonstrates the same. Please note that in case of import, take care of the conversion. In the sample, I have converted it to the “Address” class.

    Similarly, as shown in the attached demo, you could write the logic to import any Excel file.

    C1Excel API: https://developer.mescius.com/componentone/docs/win/online-excel/C1.Excel~C1.Excel_namespace.html

    Regards,

    Ankit

    FlexGrid_ImportExport…zip

  • Posted 12 November 2024, 9:13 pm EST

    Hi Ankit.

    Your example doesn’t run on my computer.

    It probably runs with .net 6.0 version, but I think it’s because our development environment is .net 7.0.

    If you change the properties to .net 7.0 and compile, it compiles, but only ‘Loading…’ appears on the screen and nothing happens. ( The grid doesn’t even appear.)

    How do I use .net 7.0 version?

  • Posted 13 November 2024, 2:42 am EST

    Hi,

    I have attached a new sample for the DotNet 7.0. Kindly try the sample and let us know if you face any issues.

    It would be better if you could mention the specifications like Project Type, DotNet Version, C1 Library version at the start so that we could share the sample based on the specifications provided.

    Regards,

    Ankit

    Import_Export.zip

Need extra support?

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

Learn More

Forum Channels