[Duplicate] Run autofit row height from command line
[Duplicate] Run autofit row height from command line
Hello! Is it possible to run OpenOffice Calc in headless mode and run autofit command (.uno:SetOptimalRowHeight) for all cells on worksheet via command line ?
Last edited by MrProgrammer on Tue May 16, 2023 2:42 pm, edited 1 time in total.
Reason: Mark topic as duplicate and lock it
Reason: Mark topic as duplicate and lock it
OpenOffice 4.1 on Ubuntu 22
- MrProgrammer
- Moderator
- Posts: 5100
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: Run autofit row height from command line
You can record a macro to perform:
• Select → All
• Format → Row → Optional Height → OK
• File → Save
If the macro is called Foo in module Tests in library Standard of My Macros you can execute the macro with:
YourPath/soffice --headless --nofirststartwizard --norestore "YourFile.ods" "macro:///Standard.Tests.Foo()"
But it's not possible to record File → Close so the file stays open after it's saved and the soffice command never finishes. If you understand how to write macros (programming) perhaps you could edit the recorded macro and add commands to close the file. From what I recall, having the macro terminate OpenOffice may be difficult since it's OpenOffice that's running the macro. I can't help further with closing the file or with terminating OpenOffice except to suggest that if you wait a sufficient amount of time the file will have been saved and you can just kill the OpenOffice process. For many files you can use a loop:
For each file do Run Macro Wait a while Kill process Done
You can probably find more additional information about steps for closing and/or terminating in Andrew Pitonyak's OpenOffice Macro Information.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
AOO 4.1.7 Build 9800, MacOS 13.7, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
Re: Run autofit row height from command line
So, if you haven't UI on server, how can you write macros there ?
OpenOffice 4.1 on Ubuntu 22
- MrProgrammer
- Moderator
- Posts: 5100
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: Run autofit row height from command line
Record (or write) and test macros on a system which does have a UI and transfer them to the server which doesn't. Macros in My Macros are stored in user profile folder 4 → user → basic. You must also transfer the files ending in xlb (Library Basic) and xlc (Library Container).
Your topic is a duplicate of Autofit row height in XLS files from Node.js application and has been locked. Continue any discussion there.
If this solved your problem please go to your first post use the Edit ☐ button and add [Solved] to the start of the Subject field. Select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
AOO 4.1.7 Build 9800, MacOS 13.7, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).