Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Thu Jul 08, 2021 4:33 pm

Hi, Team I am here to get some information about spire excel functions. that I want to know that I am uploading CSV file and then I want to convert that csv file into excel then want to fill that excel file in DataTable C#.
Thanks & Regards.

MSAQIBABBASI
 
Posts: 11
Joined: Mon Jul 05, 2021 8:08 am

Fri Jul 09, 2021 2:28 am

Hello,

Thanks for your inquiry.
In fact, you can directly export the data in the CSV file to the DataTable. Please refer to to following code.
Code: Select all
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(@"CSVToExcel.csv", ",");
            Worksheet worksheet = workbook.Worksheets[0];

            System.Data.DataTable dataTable = worksheet.ExportDataTable();


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Jul 09, 2021 12:23 pm

Hi yes I know that I can upload CSV file directly but I am trying to compare two excel file record so when I am filing both in data Table so it says Files format not match so that's why I ask you to if there's another way to convert CSV during runtime so it good to me either I have to change before uploading it CSV to Excel.
Thanks & regards.

MSAQIBABBASI
 
Posts: 11
Joined: Mon Jul 05, 2021 8:08 am

Mon Jul 12, 2021 7:54 am

Hello,

Thanks for your inquiry and sorry for the late reply as weekend.
You can refer to the following code to convert csv file to excel file and then export the data in the excel file to the DataTable.
Code: Select all
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(@"CSVToExcel.csv", ",");
           
            workbook.SaveToFile("result.xlsx",ExcelVersion.Version2016);
            workbook.LoadFromFile("result.xlsx");
            Worksheet worksheet = workbook.Worksheets[0];
            System.Data.DataTable dataTable = worksheet.ExportDataTable();


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Tue Jul 20, 2021 9:46 am

Hello,

Hope you are doing well.
Has your issue been resolved? Any feedback will be greatly appreciated.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Tue Jul 27, 2021 2:57 pm

Yes my issue has been resolved. Thanks

MSAQIBABBASI
 
Posts: 11
Joined: Mon Jul 05, 2021 8:08 am

Wed Jul 28, 2021 1:22 am

Okay, I am glad to hear that your issue has been resolved.
If you encounter any issues related to our products in the future, please feel free to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.XLS