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 13, 2020 10:13 am

Hello,

I'm creating a csv file separated with semicolons. I need to use "." as decimal separator and no miles separator (client especifications).
Is it possible to change them in spire? I mean the options marked in the attached file.

Thanks in advance,

Luis.
Attachments
Opciones Excel.jpg
Opciones Excel.jpg (118.13 KiB) Viewed 1799 times

lgomezb
 
Posts: 3
Joined: Wed Apr 17, 2019 6:45 am

Fri Feb 14, 2020 6:42 am

Hello,

Thanks for your inquiry.
What you marked in the attched image is the display settings of Microsoft Excel tool. Sorry, our Spire.XLS can only operate Excel documents, we can't modify the settings of Microsoft Excel itself.

Or you want to create a CSV file using "." as the separator? If so, you could refer to the following code.
Code: Select all
    Workbook workbook = new Workbook();
    Worksheet sheet = workbook.Worksheets[0];
    //Your code...
    sheet.SaveToFile("result.csv", ".", Encoding.UTF8);


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Feb 14, 2020 7:53 am

Hello,

I'm working with Spire xls library and Visual Basic code.
I'm saving a csv file with the ";" separator successfully.
In that file, I write quantities from a database with the "," as the decimal separator, and I need them to be saved with the "." as decimal serparator, instead of ",".
So, my question is if it's possible changing the equivalent Excel setting (showed in the attached file) in the Spire environment, to get the quantities with the "." as decimal separator.

Thanks,

Luis.

lgomezb
 
Posts: 3
Joined: Wed Apr 17, 2019 6:45 am

Fri Feb 14, 2020 10:11 am

Hello,

Thanks for your response.
You mean that you hava some data in a format like "12,00" , and you want to save it as "12.00", right? If so, you could refer to the following code to replace the "," decimal separator to ".". And attached is my output file.
Code: Select all
        Dim dt As DataTable = New DataTable
        dt.Columns.Add()
        dt.Rows.Add("12,00")
        dt.Rows.Add("34,00")
        Dim workbook As Workbook = New Workbook
        Dim sheet As Worksheet = workbook.Worksheets(0)
        sheet.InsertDataTable(dt, True, 1, 1)
        Dim i As Integer = 1
        Do While (i <= dt.Rows.Count)
            Dim range As CellRange = sheet.Rows(i).Cells(0)
            Dim text As String = range.DisplayedText
            Dim newText As String = text.Replace(",", ".")
            range.Text = newText
            i = (i + 1)
        Loop

        sheet.SaveToFile("result.csv", ";", Encoding.UTF8)

Or if your data is not like this, to help us further investigate your issue, please provide some sample data as well as your desired output for our reference. Thanks in advance.

Sincerely,
Rachel
E-iceblue support team
Attachments
attachment.zip
(342 Bytes) Downloaded 168 times
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Feb 14, 2020 10:50 am

That works.

Thanks!

lgomezb
 
Posts: 3
Joined: Wed Apr 17, 2019 6:45 am

Mon Feb 17, 2020 1:08 am

Hello,

Glad to hear that!
If you encounter any question related to our product in the future, just feel free to contact us.
Have a nice day!

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.XLS