Y yshzsl Member Jul 5, 2024 #1 Hello everyone. When I was saving the file using Save As,I cannot select another folder or change the file name.If I selected another folder or changed the scheduled saved file name,The saved file has no content, and the size is 0 KB. If I do not change the folder or file name,It can be stored normally. Code is as follows: B4X: Copy Wait For (SaveAs(File.OpenInput(File.DirInternal, "book1.xls"), "application/octet-stream", "aaa.xls")) Complete (Success As Boolean) Log("File saved successfully? " & Success) Please help me with this problem. Thanks!
Hello everyone. When I was saving the file using Save As,I cannot select another folder or change the file name.If I selected another folder or changed the scheduled saved file name,The saved file has no content, and the size is 0 KB. If I do not change the folder or file name,It can be stored normally. Code is as follows: B4X: Copy Wait For (SaveAs(File.OpenInput(File.DirInternal, "book1.xls"), "application/octet-stream", "aaa.xls")) Complete (Success As Boolean) Log("File saved successfully? " & Success) Please help me with this problem. Thanks!
Erel B4X founder Staff member Licensed User Longtime User Jul 7, 2024 #2 The problem is probably somewhere else. The folder or file name shouldn't matter. Upvote 0
Y yshzsl Member Jul 8, 2024 #3 Erel said: 问题可能出在其他地方。文件夹或文件名应该无关紧要。 Click to expand... Thanks for the answer, Erel. I think I may not describe the problem in enough detail. I use your Table class to extract the data from database,The table and the data can be displayed normally on the B4xPage page. I want to export the table data and format to Excel,I tried two methods (one using aPOI, one using Excel class),Both methods can generate "book1.xls" normally.The above problems will arise when I save book1.xls as another file by Save As. In the Save As code that you provide,The variable ion may be well defined before,But I don't know what type it is,So I define it as the Object type.I wonder if this is the problem. B4X: Copy Sub StartActivityForResult(i As Intent) Dim jo As JavaObject = GetBA Dim ion As Object = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null) jo.RunMethod("startActivityForResult", Array(ion, i)) End Sub Upvote 0
Erel said: 问题可能出在其他地方。文件夹或文件名应该无关紧要。 Click to expand... Thanks for the answer, Erel. I think I may not describe the problem in enough detail. I use your Table class to extract the data from database,The table and the data can be displayed normally on the B4xPage page. I want to export the table data and format to Excel,I tried two methods (one using aPOI, one using Excel class),Both methods can generate "book1.xls" normally.The above problems will arise when I save book1.xls as another file by Save As. In the Save As code that you provide,The variable ion may be well defined before,But I don't know what type it is,So I define it as the Object type.I wonder if this is the problem. B4X: Copy Sub StartActivityForResult(i As Intent) Dim jo As JavaObject = GetBA Dim ion As Object = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null) jo.RunMethod("startActivityForResult", Array(ion, i)) End Sub
Erel B4X founder Staff member Licensed User Longtime User Jul 9, 2024 #4 yshzsl said: I think I may not describe the problem in enough detail. I use your Table class to extract the data from database,The table and the data can be displayed normally on the B4xPage page. I want to export the table data and format to Excel,I tried two methods (one using aPOI, one using Excel class),Both methods can generate "book1.xls" normally.The above problems will arise when I save book1.xls as another file by Save As. Click to expand... All of this shouldn't matter. Do you see this behavior with the TextEditor example: [B4X] TextEditor - Save and load external files ? Upvote 0
yshzsl said: I think I may not describe the problem in enough detail. I use your Table class to extract the data from database,The table and the data can be displayed normally on the B4xPage page. I want to export the table data and format to Excel,I tried two methods (one using aPOI, one using Excel class),Both methods can generate "book1.xls" normally.The above problems will arise when I save book1.xls as another file by Save As. Click to expand... All of this shouldn't matter. Do you see this behavior with the TextEditor example: [B4X] TextEditor - Save and load external files ?
Y yshzsl Member Jul 9, 2024 #5 Erel said: All of this shouldn't matter. Do you see this behavior with the TextEditor example: [B4X] TextEditor - Save and load external files ? Click to expand... Upvote 0
Erel said: All of this shouldn't matter. Do you see this behavior with the TextEditor example: [B4X] TextEditor - Save and load external files ? Click to expand...
Y yshzsl Member Jul 9, 2024 #6 Thanks,Erel I tested the TextEditor example and it is able to save the files normally. I copied the book1.txt file to the directory where the Excel file is located, I change the book1.xls to the book1.txt in the Save As statement ,And change of the target file to aaa.Txt,Code is as follows: B4X: Copy Wait For (SaveAs(File.OpenInput(File.DirInternal, "book1.txt"), "text/plain", "aaa.txt")) Complete (Success As Boolean) Log("File saved successfully? " & Success) It is able to save the files normally,It works correctly, whether or not you select another folder or change the target file name.When I replace the book1.txt file with the book1.Xls file, making the code the same as before,It is not working properly again. Upvote 0
Thanks,Erel I tested the TextEditor example and it is able to save the files normally. I copied the book1.txt file to the directory where the Excel file is located, I change the book1.xls to the book1.txt in the Save As statement ,And change of the target file to aaa.Txt,Code is as follows: B4X: Copy Wait For (SaveAs(File.OpenInput(File.DirInternal, "book1.txt"), "text/plain", "aaa.txt")) Complete (Success As Boolean) Log("File saved successfully? " & Success) It is able to save the files normally,It works correctly, whether or not you select another folder or change the target file name.When I replace the book1.txt file with the book1.Xls file, making the code the same as before,It is not working properly again.
Erel B4X founder Staff member Licensed User Longtime User Jul 10, 2024 #7 Try to reproduce it in a small project and upload it. Upvote 0
Y yshzsl Member Jul 11, 2024 #8 Thanks for your attention, Erel. I wrote a small project on the above issues,The compressed file has been uploaded. Please help me and see where the problem is. Attachments testExcel.zip testExcel.zip 20.4 KB · Views: 298 Upvote 0
Thanks for your attention, Erel. I wrote a small project on the above issues,The compressed file has been uploaded. Please help me and see where the problem is.
Erel B4X founder Staff member Licensed User Longtime User Jul 12, 2024 #9 Which Table library are you using? And it looks like the additional jars of aPOI is missing: https://www.b4x.com/android/forum/t...writing-xls-xlsx-on-android-5.110652/#content Upvote 0
Which Table library are you using? And it looks like the additional jars of aPOI is missing: https://www.b4x.com/android/forum/t...writing-xls-xlsx-on-android-5.110652/#content
Y yshzsl Member Jul 13, 2024 #10 The Table libraries and the aPOI libraries I used have been uploaded,The additional libraries poi-3.12-android-a.jar and poi-ooxml-schemas-3.12-20150511-a.jar libraries can not be uploaded due to their large files. May I need any other additional libraries? Attachments aPOI.zip aPOI.zip 24.9 KB · Views: 296 Table.b4xlib Table.b4xlib 28.6 KB · Views: 270 Upvote 0
The Table libraries and the aPOI libraries I used have been uploaded,The additional libraries poi-3.12-android-a.jar and poi-ooxml-schemas-3.12-20150511-a.jar libraries can not be uploaded due to their large files. May I need any other additional libraries?
Erel B4X founder Staff member Licensed User Longtime User Jul 14, 2024 #11 Upload the jars to Google Drive and share a link Upvote 0
Y yshzsl Member Jul 15, 2024 #12 The jars file was uploaded to my personal server,Download link:https://yshzsl.top/download/jars.zip Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Jul 15, 2024 #13 The link doesn't work. Anyway, the Excel part has no relation to the actual behavior. You should be able to reproduce it with any file content. Upvote 0
The link doesn't work. Anyway, the Excel part has no relation to the actual behavior. You should be able to reproduce it with any file content.
Y yshzsl Member Jul 15, 2024 #14 Thanks for the guidance, Erel. Under your guidance, I found out where the problem is.In the original program, I did not refer to the ContentResolver library correctly, it is now working fine after the reference is re-added,It can store many types of files,It's amazing. Thank you once again, Erel. Upvote 0
Thanks for the guidance, Erel. Under your guidance, I found out where the problem is.In the original program, I did not refer to the ContentResolver library correctly, it is now working fine after the reference is re-added,It can store many types of files,It's amazing. Thank you once again, Erel.