incendio Well-Known Member Licensed User Longtime User Oct 2, 2017 #1 Hello guys, I have a problem with jPOI, here are my codes : B4X: Sub btnStart_Action wb.InitializeExisting(File.DirApp,"RcpMonthly.xlsx","") ws = wb.GetSheet(0) Private row As PoiRow Private Cell As PoiCell row = ws.GetRow(7) row.IsInitialized Cell = row.GetCell(1) Cell.IsInitialized Cell.ValueString = "Java" wb.Save(File.DirApp,"test.xlsx") fx.Msgbox(MainForm,"OK","Info") End Sub It raised an error : Error occurred on line: 38 (Main) java.lang.RuntimeException: Object should first be initialized (PoiRow). Line 38 point to Cell = row.GetCell(1). Where am I missing here? Thanks in advance.
Hello guys, I have a problem with jPOI, here are my codes : B4X: Sub btnStart_Action wb.InitializeExisting(File.DirApp,"RcpMonthly.xlsx","") ws = wb.GetSheet(0) Private row As PoiRow Private Cell As PoiCell row = ws.GetRow(7) row.IsInitialized Cell = row.GetCell(1) Cell.IsInitialized Cell.ValueString = "Java" wb.Save(File.DirApp,"test.xlsx") fx.Msgbox(MainForm,"OK","Info") End Sub It raised an error : Error occurred on line: 38 (Main) java.lang.RuntimeException: Object should first be initialized (PoiRow). Line 38 point to Cell = row.GetCell(1). Where am I missing here? Thanks in advance.
Erel B4X founder Staff member Licensed User Longtime User Oct 2, 2017 #2 This line does nothing: row.IsInitialized PoiSheet.GetRow returns an uninitialized row if the row is empty. B4X: Dim row As PoiRow = ws.GetRow(7) If row.IsInitialized = False Then row = CreateRow(7) End If row.CreateCellString(1, "Java") Upvote 0
This line does nothing: row.IsInitialized PoiSheet.GetRow returns an uninitialized row if the row is empty. B4X: Dim row As PoiRow = ws.GetRow(7) If row.IsInitialized = False Then row = CreateRow(7) End If row.CreateCellString(1, "Java")
incendio Well-Known Member Licensed User Longtime User Oct 2, 2017 #3 You mean ws.CreateRow. I am modifying existing excel sheet, do not want to create new row. Last edited: Oct 2, 2017 Upvote 0
incendio Well-Known Member Licensed User Longtime User Oct 2, 2017 #5 How to modifying existing excel cell? Create New row will lose existing cell format. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Oct 2, 2017 #6 This is exactly why we first check whether the row is initialized or not. Upvote 0
incendio Well-Known Member Licensed User Longtime User Oct 2, 2017 #7 Found the reason. My first codes for modifying cell will work only on an non empty cell. For an empty cell, no other choice, must use CreateRow, cause there is no initialized method for cell. Last edited: Oct 2, 2017 Upvote 0
Found the reason. My first codes for modifying cell will work only on an non empty cell. For an empty cell, no other choice, must use CreateRow, cause there is no initialized method for cell.