LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Properly Delete a Row from Excel Table

Solved!
Go to solution

Hello everyone,

 

I'm trying to implement a function where the user can delete a row of data from an Excel table. I made a very simplified example to show the problem I have. Here's the block diagram for it.

Screenshot 2025-06-26 142208.png

Screenshot 2025-06-26 142222.png

Say, for example, this is the data I have, and I want to get rid of the x.

hubi_24_0-1750941284540.png

Using RGT, I read the data from the table into an array.

Screenshot 2025-06-26 141731.png

Then I activate the row delete function, and it deletes the row from my array

Screenshot 2025-06-26 142137.png

The problem is, the "Append Table to Report.vi" only changes cells in the Excel file that are affected by the new table. Because the array has 1 row less now, the last row in the previous Excel file doesn't get changed or deleted, so the "g" in row 9 of the Excel file stays there.

hubi_24_1-1750941744294.png

And if I load the Excel table into the LabView array again, the "g" row gets doubled.

 

Furthermore, if I want to delete the last row on the table, It simply won't get deleted because the new array doesn't change that last row.

So is there a way around this? I'm very new to LabView, so there's probably many things I missed or don't quite understand yet.

 

Thanks in advance!

Download All
0 Kudos
Message 1 of 7
(157 Views)
Solution
Accepted by topic author hubi_24

Hi Hubi,

 

you could use "more low level" ActiveX nodes to select a range and delete it - the same as you would do in Excel manually or by VBA…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(144 Views)
Solution
Accepted by topic author hubi_24

Expanding on what Gerd said, you can use Excel_Insert_Cells VI as a reference.  It has everything you need.  You'll just need to change the insert method to delete. 

 

aputman
Message 3 of 7
(112 Views)

Alright, I just finished trying something out

 

I ended up creating this monstrosity, which somewhat works I guess.

hubi_24_0-1750949815391.png

Also thank you to aputman for the tip on using the Excel Insert Cells.vi as reference, which I wish I read before making this thing.

 

Cheers, Hubi

0 Kudos
Message 4 of 7
(106 Views)

Make use of the Get_ActiveX_References.  It simplifies a lot of the work.

aputman_0-1750950194563.png

 

aputman
0 Kudos
Message 5 of 7
(97 Views)
Solution
Accepted by topic author hubi_24

As said, use Excel Get ActiveX reference to simplify the code. The way you implemented your code the last row of the table will always be deleted. You need to look at the content of each row to see if there is an "x". I attached an example of a possible way to do it. Note that I start with the last row of the table because if you start with the first and delete a row the index of the last row will change. I only use the content of the first column for the comparison, you can easily modify the code if you need to compare both columns.

 

delete line from table.png

 

Ben

Message 6 of 7
(72 Views)

ActiveX functions always yield such short VIs 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 7
(31 Views)