Hi all,
I'm struggling to send data from a TableView to a CSV file formatted text file.
The tableview is populated from a database.
With a button, send the TableView rows to the CSV file.
Here's the button code, which causes a crash on line: su.SaveCSV2()
Here's 4 sample records from the SQL table (first line is column names):
TutorialID title description DateAdded Base_URL url Active
13 Cash Vault Deposits Cash Vault Deposits 2010-04-26 http://server:88/palace/DocumentsAn...Vault_Deposit&Change_Ordering_Instruction.pdf \\server2\DocumentsAndVideos\AccountingManual\6_Cash_Vault_Deposit%26Change_Ordering_Instruction.pdf 0
18 Cash Vault - Change Order BofA Cash Vault - Change Order BofA 2010-04-26 http://server:88/palace/DocumentsAn...ash_Vault_Deposit&Change_Ordering_Instruction BOA.pdf \\server2\DocumentsAndVideos\AccountingManual\6I_Cash_Vault_Deposit%26Change_Ordering_Instruction%20BOA.pdf 0
3 Contact Info. Accounting Contact Info 2010-04-22 http://server:88/palace/DocumentsAndVideos/AccountingManual/01_Contact_List.pdf \\server2\DocumentsAndVideos\AccountingManual\CONTACT LIST.docx 0
132 Purchasing Policies, Vendor Score Card, and Vendor Purchasing Policies, Vendor Score Card, and Vendor NULL \\server2\DocumentsAndVideos\PurchasingPolicy-PalaceJune2012.pdf 0
This is copied directly with headers from SQL Server Management Studio, so it is not formatted correctly for copying to this forum. Some columns data may contain NULL.
Here's B4J's error message:
Is it the data that's causing the crash or something else?
Thanx,
Mark Stuart
I'm struggling to send data from a TableView to a CSV file formatted text file.
The tableview is populated from a database.
With a button, send the TableView rows to the CSV file.
Here's the button code, which causes a crash on line: su.SaveCSV2()
B4X:
Sub btnExport_Click
Dim Hdr As List
Hdr.Initialize
Hdr.Add(Array As String("ID","Title","Description","DateAdded","BaseURL","URL","Active","FileFound"))
Dim TheItems as List = Main.tvDocs.Items
Dim su As StringUtils
su.SaveCSV2(File.DirApp, txtFilename.Text, ",", TheItems, Hdr) 'crashes on this line
End Sub
Here's 4 sample records from the SQL table (first line is column names):
TutorialID title description DateAdded Base_URL url Active
13 Cash Vault Deposits Cash Vault Deposits 2010-04-26 http://server:88/palace/DocumentsAn...Vault_Deposit&Change_Ordering_Instruction.pdf \\server2\DocumentsAndVideos\AccountingManual\6_Cash_Vault_Deposit%26Change_Ordering_Instruction.pdf 0
18 Cash Vault - Change Order BofA Cash Vault - Change Order BofA 2010-04-26 http://server:88/palace/DocumentsAn...ash_Vault_Deposit&Change_Ordering_Instruction BOA.pdf \\server2\DocumentsAndVideos\AccountingManual\6I_Cash_Vault_Deposit%26Change_Ordering_Instruction%20BOA.pdf 0
3 Contact Info. Accounting Contact Info 2010-04-22 http://server:88/palace/DocumentsAndVideos/AccountingManual/01_Contact_List.pdf \\server2\DocumentsAndVideos\AccountingManual\CONTACT LIST.docx 0
132 Purchasing Policies, Vendor Score Card, and Vendor Purchasing Policies, Vendor Score Card, and Vendor NULL \\server2\DocumentsAndVideos\PurchasingPolicy-PalaceJune2012.pdf 0
This is copied directly with headers from SQL Server Management Studio, so it is not formatted correctly for copying to this forum. Some columns data may contain NULL.
Here's B4J's error message:
B4X:
Error occurred on line: 45 (Export)
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
at anywheresoftware.b4a.objects.StringUtils.SaveCSV2(StringUtils.java:74)
at anywheresoftware.b4a.objects.StringUtils.SaveCSV(StringUtils.java:67)
at b4j.example.export._btnexport_click(export.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:613)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:228)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93)
at anywheresoftware.b4a.BA$1.run(BA.java:215)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:748)
Is it the data that's causing the crash or something else?
Thanx,
Mark Stuart
Last edited: