B4J Question exportTableViewToCSV problem

Mikelgiles

Active Member
Licensed User
Longtime User
Can someone advise me what I am doing wrong or tell me how to fix this code? This is code that I copied from the web site so I assume it works and that I am doing something wrong. Instead of ending up with a csv file with one record per TabelView row I end up with 22 records per TableView. 22 happens to be the number of columns of the TableView.

<code>
exportTableViewToCSV(tvMaster,"CashFlow.csv")



Sub exportTableViewToCSV(tv As TableView, filename As String)
Dim su As StringUtils
Dim l As List
l.Initialize
For y = 0 To tv.Items.Size - 1
tv.SelectedRow = y
Dim Row() As Object = tv.SelectedRowValues
Dim NRow(Row.Length) As String
For x = 0 To Row.Length - 1
NRow(x) = Row(x)
l.Add(NRow)
Next
Next
Try
su.SaveCSV(dirData, filename, ",", l)
Catch
Log(LastException.Message)
End Try
End Sub
</code>
 

Mikelgiles

Active Member
Licensed User
Longtime User
You are a lifesaver! I am not getting the error now and it looks to be sorting correctly. I make way too many assumptions. Maybe having a VB6 background is not an advantage! I was completely overlooking the routine where I was populating the tableview because of there being no error there. Am I now assuming correctly that some errors are not necessarily going to create a error where they are occurring?

I was also under the assumption that the Export as Zip was zipping the whole folder structure. Sometimes it is not picking up the Object folder. Is there some reason for that to happen? I know now to double-check the zipped structure though.

Again.................Thanks very much for all your help!!!
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hi mikel

I am glad it was useful to you!

For your first question: 95% of time the error will throw the correct line. Sometimes it will throw a subroutine. It may help always be sure that you are running the app in debug, because release will throw the java line and that is quite different from the corretlct b4j line. Some other times (haven't happened lately) it will throw the correct line in different module.

Export as zip will only zip the files folder not the object folder. AFAIK.
 
Upvote 0
Top