I have a .xlsx with a lot of rows of information, I wonder how can I get the last line of this document?
I'm supposed to be adding more lines to the end of the archive, every month. There is a sample of the script I'm working on:
function main(workbook: ExcelScript.Workbook) {
let selectedSheet = workbook.getWorksheet("sheet");
return JSON.stringify(selectedSheet.getRange());
}
Also tried with:
@victor_lion - it's great to hear you've found the solution! Wondering if you could also try selectedSheet.getUsedRange(true).getRowCount(), which might be a bit more efficient.
Thank you @Yutao I've solved this problem using the following script:
let columnValues = selectedSheet.getUsedRange(true).getColumn(column).getValues();
return columnValues;
And by this I get an array, so by this I know the length of the file, and can get the last line.
Hey @victor_lion ,
Wondering if you have tried Range.getSurroundingRegion( ) . I think that should work as long as there are no completely blank rows or blank columns within the range.
-Yutao
Hi, I'm looking to a function like .getUsedRange(), as I am no trying to add more content to the file.
Hi @victor_lion
You could probably get away without using Office Scripts and do something like https://www.exceltip.com/lookup-formulas/find-the-last-row-of-data-in-excel.html
WarrenBelz
146,552
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,928
Most Valuable Professional