05-25-2016 10:33 AM
Is there a way to write a value in the same cell of the same spreasheet in labview?
I just want to be able to replace the same cell in the spreasheet.
Can someone please help me?
05-25-2016 10:48 AM
What is a "spreadsheet"?
Are you talking about excel? A LabVIEW table? A 2D array? A file?
Please attach some simplified code so we get a better idea what you need. Thanks!
05-25-2016 12:20 PM
I am trying to use a write to spreadsheet vi, to replace a single cell in the tab delimitted spreadsheet.
05-25-2016 12:34 PM
You can't. Write to Spreadsheet File creates a text file.
What you would need to do is use Read From Spreadsheet File to read in the entire text file where it becomes a 2-D array. Use Replace Array Subset to replace whichever cell you want. Then use Write to Spreadsheet File to write the tab delimited text file back out again.
05-25-2016 12:37 PM - edited 05-25-2016 12:39 PM
You cannot edit values in a delimited spreadsheet files, because the field width is typically not fixed. Thus it is not possible to calculate file offset for the element location and if the new element string is longer or shorter, all later values would need to be shifted.
Solution: You need to read the entire spreadsheed, replace the value and write the changed array back.
Alternatively, if this is a numeric array, use a flat binary file instead. Now any field can be edited by writing to the correct file offset.
05-25-2016 02:36 PM - last edited on 12-16-2024 08:35 AM by Content Cleaner
I use the .NET Automation Reference to connect to Excel in many projects.
If you have the Report toolkit, you can dive into the "behind-the-scenes" of the Excel reports to see how they do things.
Also, check out this link which shows many options for getting data into Excel.
Near the bottom of the page are the .NET gory details for the adventurous do-it-yourselfer.
http://www.ni.com/newsletter/51339/en/
I have multiple subVIs to perform individual actions, like
Open the Excel application,
Open a Workbook,
Select a Worksheet,
Select a Range,
Read / Write data to / from a Range...etc..
I've created a simple demo that shows the basic steps to take.
see attachment
05-25-2016 02:38 PM
@jeffneuner wrote:I use the .NET Automation Reference to connect to Excel in many projects.
He has a plain tab delimited text file. Nothing to do with excel.
05-25-2016 08:25 PM
Well, technically, what you need to do is (a) read the entire file and organize it so you can "reach" a specified cell, (b) modify the cell, and (c) write the entire file back out.
One (the easier, sensible) way to do this is to use LabVIEW's Delimited Spreadsheet functions for steps (a) and (c), resulting in an Array handled in (b). Another (sillier, but workable) method is to (a) read the .csv file with Excel, which organizes it into an Excel Worksheet, (b) tell Excel to modify a particular Cell, then (c) write the entire Excel file back out in .csv form.
Given a sensible, easy way to do something, why not do it another, harder, more obscure way? Your customers will think you are so clever and you can earn the Big Bucks.
Bob "the Cynic" Schor