none
Write EXCEL document without Office installed RRS feed

  • Question

  • hello,

    I must write an application that write Excel files.

    I want if it is possible on developer computer not install office, while my customer that use application have installed office 2010.

    Is it possible ?

    Stefano

    Thursday, June 15, 2017 9:39 AM

All replies

  • Hello Stefano, 

    What about creating openxml files?  I would find it very challenging to create Excel files though without a way of verifying them though (not having excel installed).


    Cheers, Jeff

    Friday, June 16, 2017 12:53 AM
  • Hello Stefano,

    You can consider using some 3rd party libraries, I would suggest you take a look at https://www.nuget.org/packages/FreeSpire.XLS/, this free version supports a variety of Excel manipulations like create, write, edit and convert Excel files, and you can easily integrate it in your applications even though you are not familiar with it at the beginning. There are also many tutorials in their official website to help you get started quickly.



    Friday, June 16, 2017 2:09 AM
  • Hi Stefano74,

    You could use ado.net to achieve it without installing excel.

    And the following code for your reference.

    string dataPath = @"D:\Data\Test.xlsx";
                string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " + dataPath + ";Extended Properties=\"Excel 12.0 Xml; HDR = YES\";";
                DataTable dt = new DataTable();
                OleDbConnection con = new OleDbConnection(connectionString);
                string str = $"SELECT * FROM [Sheet1$]";
                OleDbCommand com = new OleDbCommand();
                com = new OleDbCommand(str, con);
                con.Open();
                OleDbDataAdapter oda = new OleDbDataAdapter(com);
    
                oda.Fill(dt);
    
                foreach (DataRow dr in dt.Rows)
                {
                    Console.WriteLine("{0}  --- {1}   --- {2}", dr[0], dr[1], dr[2]);
                }
    
    
                con.Close();
                Console.ReadLine();

    For more information about insert data into excel, please refer to:

    https://stackoverflow.com/questions/12148111/easiest-way-to-insert-simple-data-into-an-excel-file-from-net

    But the ACE provider is not installed on Windows operating systems by default. You have to install it. The ACE provider is available in two forms: Microsoft Office Access database engine 2007 and  the Microsoft Access Database Engine 2010 Redistributable. The 2007 version is only available as a 32-bit component whereas the 2010 version offers both 32 and 64-bit options. You need to be careful which option you choose, because a wrong choice here is the most frequent cause for the error message.

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 16, 2017 6:57 AM
    Moderator