B4J Question jPOI - Excel change cells

Tayfur

Well-Known Member
Licensed User
Longtime User
I used for delete row on sheet.

B4X:
Dim wb As PoiWorkbook
dim Sheet_SIPARIS As PoiSheet

    wb.InitializeExisting("Foldername","file name","")
    If wb.IsInitialized Then
    Sheet_SIPARIS=wb.GetSheet(0)
    Dim row As PoiRow
    For i=Sheet_SIPARIS.FirstRowNumber+1 To Sheet_SIPARIS.LastRowNumber
        row=Sheet_SIPARIS.CreateRow(i) ' this line delete line on selected sheet
    Next
end if
wb.save("Foldername","file name")
wb.Close


I used for change cell row on sheet.

B4X:
Dim wb As PoiWorkbook
dim Sheet_SIPARIS As PoiSheet

    wb.InitializeExisting("Foldername","file name","")
    If wb.IsInitialized Then
    Sheet_SIPARIS=wb.GetSheet(0)
    Dim row As PoiRow
   
        row=Sheet_SIPARIS.getRow(1) ' this line read line on selected sheet
    Dim poicells As PoiCell 
poicells= row.CreateCellString(0, DateTime.Date(datetime.now)) 'this line change volues on cell(1,0) 
end if
wb.save("Foldername","file name")
wb.Close
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
Load the workbook, get the sheet, get the row and then get the cell. Now you can change the cell value. Don't forget to save when done.

You can remove a sheet with:
B4X:
Dim jo As JavaObject = Workbook1
jo.RunMethod("removeSheetAt", Array(<index of sheet here>)) '0 to remove the first one
thank for helps.
 
Upvote 0
Top