0

Hi,

i am using visual studio 2015 and trying to export data which i am importing through excel by the user selected Excel file. Now the importing part has been successfully completed i am using OLEDB Connection but Stuck in exporting the same data to a new Excel file. tried many things but nothing's been working so far. here is the code which i tried :

FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read);

        //1. Reading from a binary Excel file ('97-2003 format; *.xls)
      //  IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
        //...
        //2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
        IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);

        //...
        //3. DataSet - The result of each spreadsheet will be created in the result.Tables
        DataSet result = excelReader.AsDataSet();
        //...
        //4. DataSet - Create column names from first row
        excelReader.IsFirstRowAsColumnNames = true;
        DataSet result = excelReader.AsDataSet();

        //5. Data Reader methods
        while (excelReader.Read())

            //excelReader.GetInt32(0);

        //6. Free resources (IExcelDataReader is IDisposable)
        excelReader.Close();

i also added nuget packet IExcelDataReader but nothing seems to be working.Please Help.

2
Contributors
3
Replies
16
Views
9 Months
Discussion Span
Last Post by Reverend Jim
0

i am using datagridview in which i am importing data and user can make changes so need those changes to be saved and export the saved content to a new excel file saving and everything has been accomplished just not getting through with the exporting.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.