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 Feb 11, 2021 10:19 pm

After converting a .csv file to .xlsx, all of the numbers are stored as text. Calculations still work correctly in othee sheets that references this data. But I want the numbers to be stored as numbers. What is the syntax to do this with Vbnet and Spire.XLS after the file conversion?

Thanks

csv to xlsx.png
csv to xlsx.png (5.49 KiB) Viewed 835 times

skyfox1964
 
Posts: 9
Joined: Sun Oct 11, 2020 2:30 pm

Fri Feb 12, 2021 11:15 am

Hello,

Thanks for your inquiry.
Please refer to the following code to keep the numbers in the worksheet to be stored as numbers
Code: Select all
        Dim workbook As Workbook = New Workbook
        workbook.LoadFromFile("test.csv", ",", 1, 1)
        Dim sheet As Worksheet = workbook.Worksheets(0)

        sheet.Range("A1:E5").ConvertToNumber()
        workbook.SaveToFile("result.xlsx", ExcelVersion.Version2016)

If this doesn't meet your requirement well, please provide your input file along with your desired output file. Then we will investigate it further.

Sincerely,
Brian
E-iceblue support team
User avatar

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

Sat Feb 13, 2021 6:04 am

Thanks Brian.

That fixed the issue.

Cheers!

skyfox1964
 
Posts: 9
Joined: Sun Oct 11, 2020 2:30 pm

Mon Feb 15, 2021 1:23 pm

Hi,

Thanks for your feedback.
If you have other questions, please feel free to write back.
Wish you all the best!

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.XLS

cron