How to make write range NOT delete the cell format in excel

Hi!

I am trying to write an excel file in which I must place a ####. ### 0 format number within a specific column of the table, this number is contained in a data table. The problem is that at the time of writing the number in the cell in “general” format, delete the number 0 at the end of the number chain and I need that 0 to be there.

Already trying to change the cell format to “text” before writing, the problem is that when I write the data table inside Excel using Write or Append Range, the cell returns to the “general” format even though before writing I had it as “text.”

Does anyone have any idea how to solve the problem?

image

Hi @AS_Deloen

Your datatable column must be in general data type. So when its writing to excel, it must be changing it. Have you tried changing the column of the data table to a string type?

You might not be able to change it directly when your datatable has data in it. You have two options here…

  1. Use a build datatable activity to build your data table in the required format, and then read the data to that data table. This will have all the data in the format you specify for each column

  2. If first option is not possible, create a new column in the data table with string type. Then use a for each row activity to loop through the data table and assign the value of the problem column to the new column which has the desired data type. Once done, remove the old column. Now write it to the excel and see what happens…

Let know whether it helps…

2 Likes

I solved it in a similar way you as indicated. I used a for each to move the data from one dt to another with string format in its columns, later I converted the excel columns to the text format and wrote the new dt with an append range.

Thanks for you´re help!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.