B4J Question Problem with reading Excel.xls (B4XTable)

GMan

Well-Known Member
Licensed User
Longtime User
I am playing around with the Excel import.

Here is my code so far (taken over 1:1 from Erel 's example:

B4X:
#Region Project Attributes
    #MainFormWidth: 1200
    #MainFormHeight: 600
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private B4XTable1 As B4XTable
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("1") 'Load the layout file.
    MainForm.Show
    B4XTable1.AddColumn("Artikel", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("Betrag", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("Artikelbezeichnung", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("Steuersatz", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("VK ohne Versand", B4XTable1.COLUMN_TYPE_TEXT)
    Dim poi As PoiWorkbook
    poi.InitializeExisting(File.DirApp, "Mappe4.xls", "")
    Dim sheet As PoiSheet = poi.GetSheet(0)
    Dim data As List
    data.Initialize
    For Each row As PoiRow In sheet.Rows
        If row.RowNumber > 5 Then
            Dim DataRow(5) As Object
            DataRow(0) = row.GetCell(0).ValueString 'country
            DataRow(1) = row.GetCell(1).ValueString '.Trim 'region
            DataRow(2) = row.GetCell(2).ValueString 'population
            DataRow(3) = row.GetCell(3).ValueString '.Trim 'region
            DataRow(4) = row.GetCell(4).ValueString 'population
            data.Add(DataRow)
        End If
    Next
    B4XTable1.SetData(data)
    poi.Close
End Sub

With the example file Countries of the world.xls it works, but not with mine file - nothing is shown in the table except the header row
Saved it as a 2003-compatible .xls file because newer files ended with .xlsx
 

GMan

Well-Known Member
Licensed User
Longtime User
And do you have evidence that this brings any value?

Value?:
For Each row As PoiRow In sheet.Rows
When i use the countries of the world.xls it works fine
 
Upvote 0
Top