B4J Question XLUtils, Read and Write the same Excel File.

rasaliad

Member
Licensed User
Longtime User
Hi all,

How Can I Open an existing excel file read and write some cells and then save it. I mean Open an excel file to read and write a the same time using XLUTILS.

Thanks!!!
 

walt61

Active Member
Licensed User
Longtime User
Hi @rasaliad , e.g. like this:
B4X:
' Open the workbook
Dim workbook As XLWorkbookWriter = xl.CreateWriterBlank 
'Or:
Dim workbook As XLWorkbookWriter = XL.CreateWriterFromTemplate("YourWorkbookPath.xlsx", "")

' Read row 1 of 'Sheet1'; row numbers are zero-based
Dim row As PoiRow = workBook.PoiWorkbook.GetSheetByName("Sheet1").GetRow(0)

' Write cell D5 of 'Sheet2'
Dim sheetWriter As XLSheetWriter = workBook.CreateSheetWriterByName("Sheet2")
sheetWriter.PutString(XL.AddressOne("D", 5), "Hi there")
 
Upvote 1

rasaliad

Member
Licensed User
Longtime User
Hi @rasaliad , e.g. like this:
B4X:
' Open the workbook
Dim workbook As XLWorkbookWriter = xl.CreateWriterBlank
'Or:
Dim workbook As XLWorkbookWriter = XL.CreateWriterFromTemplate("YourWorkbookPath.xlsx", "")

' Read row 1 of 'Sheet1'; row numbers are zero-based
Dim row As PoiRow = workBook.PoiWorkbook.GetSheetByName("Sheet1").GetRow(0)

' Write cell D5 of 'Sheet2'
Dim sheetWriter As XLSheetWriter = workBook.CreateSheetWriterByName("Sheet2")
sheetWriter.PutString(XL.AddressOne("D", 5), "Hi there")
Hi Walt61, thanks very much!!!

Your code gave me the guidelines to make mine work. I love this Forum, they always have help at hand.

Thanks again.
 
Last edited:
Upvote 0
Top