# Writing to an Excel range

**URL:** <https://forum.uipath.com/t/excel/5743027>\
**Category:** フォーラム\
**Created:** [May 1, 2026, 7:33am UTC](https://forum.uipath.com/t/excel/5743027 "2026-05-01T07:33:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kana612](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kana612/32/179008_2.png) [@kana612](https://forum.uipath.com/u/kana612)\
**Post date:** [May 1, 2026, 7:33am UTC](https://forum.uipath.com/t/excel/5743027/1 "2026-05-01T07:33:16Z")

</div>

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.

 ![image](https://global.discourse-cdn.com/uipath/original/4X/9/2/e/92ee6e9f40f4192e66184fbf5f8e7df1b81e0c6d.png)

---

<div class="post-metadata">

**Author:** ![kana612](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kana612/32/179008_2.png) [@kana612](https://forum.uipath.com/u/kana612)\
**Post date:** [May 1, 2026, 8:04am UTC](https://forum.uipath.com/t/excel/5743027/2 "2026-05-01T08:04:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JarrydScott](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jarrydscott/32/557333_2.png) [@JarrydScott](https://forum.uipath.com/u/JarrydScott)\
**Post date:** [May 1, 2026, 9:57am UTC](https://forum.uipath.com/t/excel/5743027/3 "2026-05-01T09:57:11Z")

</div>

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:

 ![image](https://global.discourse-cdn.com/uipath/original/4X/3/e/3/3e36a5a77b1d8333b52c0e5dc5f686755037a8b5.png)

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 🙂

---

<div class="post-metadata">

**Author:** ![kana612](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kana612/32/179008_2.png) [@kana612](https://forum.uipath.com/u/kana612)\
**Post date:** [May 7, 2026, 1:38am UTC](https://forum.uipath.com/t/excel/5743027/4 "2026-05-07T01:38:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [May 7, 2026, 2:01am UTC](https://forum.uipath.com/t/excel/5743027/5 "2026-05-07T02:01:29Z")

</div>

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)?

---

<div class="post-metadata">

**Author:** ![kana612](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kana612/32/179008_2.png) [@kana612](https://forum.uipath.com/u/kana612)\
**Post date:** [May 7, 2026, 2:13am UTC](https://forum.uipath.com/t/excel/5743027/6 "2026-05-07T02:13:19Z")

</div>

The version of UiPath.Excel.Activities is 2.24.4.  
I encountered the same exception with 3.5.1 as well.

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [May 7, 2026, 2:17am UTC](https://forum.uipath.com/t/excel/5743027/7 "2026-05-07T02:17:58Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kana612](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kana612/32/179008_2.png) [@kana612](https://forum.uipath.com/u/kana612)\
**Post date:** [May 7, 2026, 4:44am UTC](https://forum.uipath.com/t/excel/5743027/8 "2026-05-07T04:44:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [May 10, 2026, 4:45am UTC](https://forum.uipath.com/t/excel/5743027/9 "2026-05-10T04:45:36Z")

</div>

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