B4J Question How to use FileChooser in B4J

Fabrice La

Active Member
Licensed User
Longtime User
In my B4J appli, I am using WritableWorkbook to write an Excel file.
When the file is done I would that the appli open FileChooser to save the excel file where the user want it.

B4X:
newWorkbook.Write
newWorkbook.Close
Dim fc As FileChooser
fc.Initialize
fc.InitialFileName = "excelfile.xls"
fc.SetExtensionFilter("Excel Files",Array As String("*.xls"))
Dim fileName As String = fc.ShowSave(MainForm)
If fileName <> "" Then
  If fileName.ToLowerCase.EndsWith(".xls") = False Then fileName = fileName & ".xls"
  Dim out As OutputStream = File.OpenOutput("", fileName, False)
  out.Close
  Log("File saved: " & fileName)
End If

I don't know how this filechooser showsave works did not find example.
 

stevel05

Expert
Licensed User
Longtime User
You have the ShowSave working, I haven't used the Excel lib, but you would have initialized newWorkbook to a file somewhere on the storage. Don't you just need to copy that (File.Copy) to the location the user chose, then delete (File.Delete) the original?
 
Upvote 0
Top