Excel saves automatically

datatable
excel

#1

Hello everyone,

I am currently working on a robot that goes through a database et writes cell in another excel files.
The excel file saves everytime I write one cell so it takes a long time …
Is there a way to save only at the end to improve the performance ?

Best regards,
Thomas


Aut save disabling in excel after each write cell
#2

Hi @lemoinethomas,

  1. You can build a data table, you can use Build Data Table activity.
  2. You can keep adding your rows in between your process by using Add Data Row Activity.
  3. At the end you can directly write that temporary/newly created data table (which you filled during your process) using Write Range Activity. This activity accepts a data table to write into the excel file.
  4. Hence instead of writing each time you can write the data once to excel file.

Hope this logic will work in your case, if i have understood your problem.
Give a try.
Regards,
Jiban


#3

Thank you very much for your answer. It could work and seems to be the best practice but I need to write in specific cells of an already existing excel file …


#4

By the way it doesn’t seem to work if the excel file is not opened.
I get this error right away : Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

It doesn’t happen when the file is opened on my desktop


#5

Hey @lemoin

  1. If you want to write to specific cells then we have to choose the particular Cell, so we have to use the write cell activity. You have to compromise then with the performance.
  2. If you slightly modify your logic, then you can use SQL Query also to retrieve and to update data in Excel sheet. First check if this SQL Query method will meet your requirements.
  3. Make sure that you have closed your excel file (used in code) if you are dealing with excel activity. If you don’t close it, then the Robo will face a deadlock condition and throw exception that the file is being used by another application/process.
  4. Check your excel template if they have some formatting to that particular cell. Check The Parameter what You are Passing. Example: u may Be Passing String which has value for integer

Note: If you can share some detailed information/workflow then it will help us to understand in depth.

Regards,
Jiban


#6

Thank you for your answer, I will have to compromise with perfomance :wink:

My main problem is this error : Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) when the destination file is not opened.

UiPathForum.xaml (61.2 KB)

Please find attached my workflow, JDD is the source file (csv) and Matrice is the destination file.

Best regards,


#7

How do I add data row from a scrapped data?


#8

What is the scrapped data? Is it a string value or a data table?


#9

It’s a data table. We can’t add data table into data row right? If that is the case, how should i go with it?


#10

If it is a data table, first use a for each row activity and fetch all the required fields from that data table and store them in different variables.
In Add Data Row activity: Pass one data Array in the form of Ex: {variable1,variable2}
Note: Before you add the data using add data row activity, make sure that you have a empty data table and
the number of values you are going to add = the number of columns you have in the empty data table.


#11

Perfect, I’ll try to work on it from here. Thanks mate.