I have an app with an sqlite backend database. What I would like to do is query the database for three fields in a table and …
Open an existing “Pages” file (a new file if I have too) and dump the contents of the recordset in to the Pages file, and then save the pages file to the desktop.
Or.. If I had the 3 fields of data in a listbox, just export the listbox to a “Pages” file
Is this possible? If so, any quick thoughts would really be appreciated.
Thanks
Do you mean Pages (document layout) or Numbers (spreadsheets)? Sounds like you’re exporting data in a table format, which suggests spreadsheet…
Thanks!! I do want to export them to a ”numbers file”.
the ultimate end state would be to export the 3 fields from a record set or a list box to a numbers file, and in code add a password to that numbers file.. and save the file to the desktop
Thanks
Numbers uses a proprietary file format that you probably shouldn’t bother trying to reverse engineer. So you’ll have to use AppleScript to automate the creation, password setting, and saving of the file.
Thanks. I’ve never used an apple script. Can you point me in the right direction to a tutorial of some type?
Just ask ChatGPT for help with AppleScript.
You can easily create a CSV file for Numbers. If you want to get fancy do an Excel file either with MBS or Einhugur.
1 Like
He wants it to be password protected. Amazingly, despite Apple’s ongoing neglect of AppleScript, Numbers supports adding a password to a file vía scripting.
1 Like
Well… Keep in mind I am a rookie..
After two hours of goggling and trying (and failing) to make it work, I tried ChatGBT. In 5 min I had something running.. 
MUCH THANKS to all!
So this is what I got to work, simple, I like it…
set csvFile to POSIX file “/Users/Home/Desktop/Data.txt”
set saveFile to POSIX file “/Users/Home/Desktop/data.numbers”
tell application “Numbers”
set doc to open csvFile
set password “password” to first document
save doc in saveFile
close doc
end tell
So next step. How do I Call this from within my XOJO app. And can I somehow pass it the filepaths of csvFile and saveFile instead of them being hardcoded into the script.
As far as I remember you can pass parameters into the AppleScript. I prefer using MBS or osascript where I can build the scripts in code. Oh, and don’t do your first script in a thread on Tahoe because of Apple stupidity.
But you need to learn about entitlements for AppleScript. Otherwise, your script will fail in a Xojo app.
Oh, and don’t do your first script in a thread on Tahoe because of Apple stupidity.
What does this mean? What bad thing is Tahoe doing?
Some more reading for you that might answer questions: PSA: don't do your first AppleScript in a thread