how To Delete empty columns in collection?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
29-03-22 08:35 AM
I have 500 rows and 150 columns in excel sheet which I am copying into collection (using Get worksheet as collection). Out of 150 columns, around 80 are empty. How should I delete those empty columns? If I use 'delete column' action, it will ask for column name but I want delete all null columns in one go. Please suggest.
------------------------------
Hari bp
------------------------------
------------------------------
Hari bp
------------------------------
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
29-03-22 11:40 AM
Hi H,
I would suggest looking into the OLEDB actions as delivered by BP. It allows you to extract data from an XL and put it into a collection. OLEDB runs a regular SQL statement to define what data needs to be extracted, this allows you to omit empty rows or select rows based on cells with a certain value.
Alternatively, you just read the XL into a collection unsing the regular XL into Collection action, and then run the collection-action to remove empty rows. The regular action to get XL data into a collections has its limitations to the volume of data. But according to a recent post by Eric, a new/extended VBO is available that does handle larger volumes without OutOfMemory errors.
------------------------------
Happy coding!
Paul
Sweden
------------------------------
I would suggest looking into the OLEDB actions as delivered by BP. It allows you to extract data from an XL and put it into a collection. OLEDB runs a regular SQL statement to define what data needs to be extracted, this allows you to omit empty rows or select rows based on cells with a certain value.
Alternatively, you just read the XL into a collection unsing the regular XL into Collection action, and then run the collection-action to remove empty rows. The regular action to get XL data into a collections has its limitations to the volume of data. But according to a recent post by Eric, a new/extended VBO is available that does handle larger volumes without OutOfMemory errors.
------------------------------
Happy coding!
Paul
Sweden
------------------------------
Happy coding!
Paul, Sweden
(By all means, do not mark this as the best answer!)
Paul, Sweden
(By all means, do not mark this as the best answer!)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
29-03-22 02:23 PM
Try with this-
Open Excel VBO and just for your comfort duplicate 'Remove Blank Rows' action, and rename the action into 'Remove Blank columns' and then open the code stage of the action and replace "Row" with "Column" and "Rows" with "Columns"
------------------------------
Ravi Kumar
Sr Automation Designer
Ericsson
Asia/Kolkata
------------------------------
Open Excel VBO and just for your comfort duplicate 'Remove Blank Rows' action, and rename the action into 'Remove Blank columns' and then open the code stage of the action and replace "Row" with "Column" and "Rows" with "Columns"
Dim worksheet As Object
worksheet = GetWorkbook(handle,Nothing).ActiveSheet
Const xlCellTypeLastCell As Integer = 11
Dim FirstColumn As Integer = 1
Dim LastColumn As Integer = worksheet.Cells.SpecialCells(xlCellTypeLastCell).Column
For i As Integer = LastColumn To FirstColumn Step -1
If worksheet.Application.CountA(worksheet.Columns(i)) = 0 Then
worksheet.Columns(i).Delete
End If
Next
------------------------------
Ravi Kumar
Sr Automation Designer
Ericsson
Asia/Kolkata
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
10-07-24 01:20 PM
I am guessing this issue is solved judging by the age of the post but I solved a similar issue with this Utility.
