B4J Question SaveCSV2

MarcoRome

Expert
Licensed User
Longtime User
Hi All, i have this code:
B4X:
    Dim CSVHeaders As List
    CSVHeaders.Initialize2(Array As String("DESCRIZIONE","Qta Iniziale", "Residuo Magazzino","Qta Cantieri", "CANTIERE ROSSI","CANTIERE GIALLI","CANTIERE TEST"))
    Dim data As List
    data.Initialize2(Array As String("1","2","3","4","5","6","7"))
    Dim su As StringUtils
    su.SaveCSV2(File.DirApp, "export.csv",",", data,CSVHeaders)

and this error:


Where i wrong ?
 

klaus

Expert
Licensed User
Longtime User
SaveCSV2 needs a List of Arrays for the table?
One array per row.
B4X:
    Dim CSVHeaders As List
    CSVHeaders.Initialize2(Array As String("DESCRIZIONE","Qta Iniziale", "Residuo Magazzino","Qta Cantieri", "CANTIERE ROSSI","CANTIERE GIALLI","CANTIERE TEST"))
    Dim data As List
    Dim row() As String  = Array As String("1","2","3","4","5","6","7")
    data.Initialize
    data.Add = row
    Dim su As StringUtils
    su.SaveCSV2(File.DirApp, "export.csv",",", data,CSVHeaders)
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Thank you for your reply Klaus.I did a previous test with row (0) .. etc but I still had the error. I will try
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
B4X:
    Dim CSVHeaders As List
    CSVHeaders.Initialize2(Array As String("DESCRIZIONE","Qta Iniziale", "Residuo Magazzino","Qta Cantieri", "CANTIERE ROSSI","CANTIERE GIALLI","CANTIERE TEST"))
    Dim data As List
    Dim row() As Object  = Array ("1","2","3","4","5","6","7")
    data.Initialize
    data.Add(row)
    Dim su As StringUtils
    su.SaveCSV2(File.DirApp, "export.csv",",", data,CSVHeaders)

Error was

B4X:
Dim row() As Object  = Array ("1","2","3","4","5","6","7")
data.Add = row
correct
B4X:
Dim row() As String  = Array As String("1","2","3","4","5","6","7")
data.Add(row)
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…