B4J Question xls/xlsx to csv using jPoi

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
I tried that code, it has a few problems
a, can only handle xls workbooks.
b, prints the output doesn't write a csv file.
c, the csv output isn't valid when loaded back into a spreadsheet.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It should be quite simple.

Something like this:
B4X:
Dim wb As PoiWorkbook
wb.InitializeExisting("...", "", "")
Dim sheet1 As PoiSheet = wb.GetSheet(0)
Dim table As List
table.Initialize
For Each row As PoiRow In sheet1.Rows
   Dim cells As List = row.Cells
   Dim r(cells.Size) As String
   For i = 0 To cells.Size - 1
       Dim cell As PoiCell = cells.Get(i)
       r(i) = cell.Value
   Next
   table.Add(r)
Next
You can then use CSVParser class to convert it to CSV: https://www.b4x.com/android/forum/threads/110901/#content
 
Upvote 0
Top