none
Create Excel file in Universal Windows App or in Window Store App RRS feed

  • Question

  • Hi Experts I am learning to develop universal windows app using visual studio 2015. I want to implement a function to create an Excel file then write data in this excel file, in my app. I try to develop it in C# adding reference Microsoft.Office.Interop.Excel. Generate Error: Missing compiler required member System.Runtime.InteropServices.LCIDConversionAttribute Search this error and find windows store apps doesn't support Microsoft.Office.Interop.Excel. I am not able to create Excel file. I do not want to use any commercial library (like syncfusion) for this. How Can I create Excel file in Universal Windows App or in Window storeApp? Please request to tell me any solution.

    Thanks
    Tuesday, November 3, 2015 5:49 AM

Answers

  • Hi KumarSharad,

    Well, if you do not want to use any commercial libraries, I would have following suggestions for you:

    #1, Excel application can also open the .csv files, by which you can simply output your text, comma is used to move to the next colume, and line break is to move to next row.

    #2, http://pauliom.com/2015/06/25/read-and-edit-openxml-docs-word-excel-etc-in-windows-10-with-c/ seems like a possible solution, but I've not test it yet, you could test it to see if it works.

    Anyway, as I read from https://www.syncfusion.com/products/communitylicense looks like it could be free if you are small business and individual developers

    --James

    ==

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, November 4, 2015 8:15 AM
  • Hi KumarSharad,

    >> Now I try using OpenXml opensource library

    I am not familiar with UWP, but as my research, it seems OpenXml is not supported in UWP, you could refer the link below for more information.
    # [UWP][C#] Using OpenXML SDK for Universal Apps
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/1a63e065-58f8-4915-8c0d-31e3aa9a71a1/uwpc-using-openxml-sdk-for-universal-apps?forum=wpdevelop

    I suggest you check the suggestion from James, and follow the steps in the link. With the second link, it shared how to read and edit excel file, I am not sure whether it could create excel file, but I think you could copy from one exist file, and then edit it with the steps.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, November 5, 2015 9:52 AM

All replies

  • Thanks Alice for reply

    As you told C#XLS component  Free version is limited to 5 sheets per workbook and 150 rows per sheet. For more than 5 worksheets there is commercial Edition of Spire.XLS. But i do not want use any commercial library. Is there  no other method in any language (like in VB/VC++) to create Excel file in universal windows App ? Any API.

    Thanks

    Wednesday, November 4, 2015 6:47 AM
  • Hi KumarSharad,

    Well, if you do not want to use any commercial libraries, I would have following suggestions for you:

    #1, Excel application can also open the .csv files, by which you can simply output your text, comma is used to move to the next colume, and line break is to move to next row.

    #2, http://pauliom.com/2015/06/25/read-and-edit-openxml-docs-word-excel-etc-in-windows-10-with-c/ seems like a possible solution, but I've not test it yet, you could test it to see if it works.

    Anyway, as I read from https://www.syncfusion.com/products/communitylicense looks like it could be free if you are small business and individual developers

    --James

    ==

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, November 4, 2015 8:15 AM
  • Thanks Jamles for reply

    Now I try using OpenXml opensource library. Now problem is it generate error WMC9999: Cannot find type System.ComponentModel.TypeConverter in module System.dll. My steps Are First create a new Universal Windows project in C# then add a reference to (C:\Program Files (x86)\Open XML SDK\V2.5\lib\DocumentFormat.OpenXml.dll) OpenXml library now addfollowing namespace

    using DocumentFormat.OpenXml;
    using DocumentFormat.OpenXml.Packaging;
    using DocumentFormat.OpenXml.Spreadsheet;

    Now on a button click add code

    string fileName = "d:\\csharp-Excel.xls";
    DocumentFormat.OpenXml.Packaging.SpreadsheetDocument spreadSheet = null;
    DocumentFormat.OpenXml.Packaging.SharedStringTablePart sharedStringTablePart;
    DocumentFormat.OpenXml.Packaging.WorkbookStylesPart workbookStylesPart;

          
    // Create the Excel workbook
    spreadSheet = DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Create(fileName, DocumentFormat.OpenXml.SpreadsheetDocumentType.Workbook, false);

    It genrate error for WindowBase.dll Reference Now I add it, next error System.Xaml.dll I also add it Now next error is C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v14.0\8.2\Microsoft.Windows.UI.Xaml.Common.targets(350,5): Xaml Internal Error error WMC9999: Cannot find type System.ComponentModel.TypeConverter in module System.dll.

    To solve this I try to add reference System.dll but system reference not add and generate message already add by default. How solve this problem . If I create a simple C#(WindowForm) project and follow same step no problem and work fine. Problem in universal App . I follow the following C# code  http://www.codeproject.com/Articles/371203/Creating-basic-Excel-workbook-with-Open-XML

    Thanks

    Thursday, November 5, 2015 8:46 AM
  • Hi KumarSharad,

    >> Now I try using OpenXml opensource library

    I am not familiar with UWP, but as my research, it seems OpenXml is not supported in UWP, you could refer the link below for more information.
    # [UWP][C#] Using OpenXML SDK for Universal Apps
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/1a63e065-58f8-4915-8c0d-31e3aa9a71a1/uwpc-using-openxml-sdk-for-universal-apps?forum=wpdevelop

    I suggest you check the suggestion from James, and follow the steps in the link. With the second link, it shared how to read and edit excel file, I am not sure whether it could create excel file, but I think you could copy from one exist file, and then edit it with the steps.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, November 5, 2015 9:52 AM