I am using UiPath.Excel.Activities.WriteRange to write a DataTable to Excel.
When the columns of the Excel I am writing to are hidden, I receive the error “Write Range (Workbook): Cannot write to the target range because it contains hidden rows. Please unfilter or unhide the rows and try again.”
(In fact, there are no hidden rows, only hidden columns.)
Please let me know if there is a way to write while keeping the columns hidden.
As for the background, until now, we had been directly specifying the file path for the “Write Range” activity, which allowed us to write even if the columns were hidden. However, when we converted this method to use on Windows, it caused the Excel files to become corrupted. (Not all files are corrupted, but the cause of the corruption is unknown.) Therefore, after changing to use it within the Excel Application Scope, we found that we could not write when the columns were hidden. However, it has prevented file corruption.
Hello @kana612
This seems like a tricky one. But perhaps this can help you.
I had a similar issue before with writing to hidden columns in Excel, what I did was invoke VBA script into the Excel file to “unhide” all columns in that range/workbook. So you can do it like this:
You can simply create a text file and reference the path in the “Code file path” field. Inside the text file you can use this code to unhide all columns/rows:
Sub UnHideAllColumns()
Cells.EntireColumn.Hidden = False
End Sub
Alternatively, you can just use an “Invoke Code” activity and place this code in the activity:
worksheet.Range("A:Z").EntireColumn.Hidden = False
But just make sure to reference your workbook and range accordingly.
Let me know if this helps ![]()
Thank you for the advice.
I would be happy if it were possible to perform a “Write Range” even when the column is hidden, but does that mean there is no such method?
Even if I have to unhide it to process, it would be helpful if it could be implemented entirely within UiPath.
Hello
What version of the UiPath.Excel.Activities package are you using? Does the same exception occur with the latest stable version (3.5.1)?
The version of UiPath.Excel.Activities is 2.24.4.
I encountered the same exception with 3.5.1 as well.
When writing through the Excel application, this issue occurs. However, if using the latest stable version, does the file still get corrupted when writing using range writing (workbook) alone?
I was able to process it without any errors or file corruption when I used the latest version and the Write Range function alone! Thank you.

