How to export all sheets from a xls files?

i want to xls files convert to pdf,special the xls files have multi sheet, use the command line

libreoffice6.2 -env:UserInstallation=file:///$HOME/.libreoffice-headless/ --headless --convert-to pdf /data/shared/xls/沪2022企业3月2.xls --outdir /data/shared/xls

generate pdf file, but there is have a problem, when the number of table rows exceeds 45, the table contents below 45 will be lost, so i want split excel sheet into mulit xls files, but i haven’t found a perfect way to split the excel sheet, keep the original format of the table after splitting

So, if you could create a multi-page pdf from your xls, there would be no need to split the xls?

No, it will go to the next page. Or have you something specific configured in your file? Then you need to explain better, why does something unusual happens in your case. A sample XLS, and a resulting PDF could clarify this.

sample XLS image:


convert to pdf:

yes, you’re right, when i copy this sheet to new xls fils, like this:

conver to pdf is normal.
image
so, i want to split sheet into mulit xls files.

You haven’t provided any XLS files, only some images. Without something that others can open and inspect settings, people would be unable to help.

this is a smaple XLS files
沪2022企业3月_0.xls (9.5 KB)
sorry, i am not familiar with some functions of this platform for the first time

:slight_smile: But in this file, the data is only 39 rows. You wrote that the problem appears when the data exceeds 45 rows. I tried to copy rows below, and it printed OK, even using the obsolete version 6.2 that had EOLed already in 2019:

沪2022企业3月_0.pdf (101.8 KB)

Please attach a document that shows the problem!

sorry, I uploaded the wrong file :pensive:
here, this is source file:
沪2022企业3月.xls (188 KB)

There are wrong settings in the Page Style. The orientation property is “Portrait”, but the Page size Width/Height values (ratio) determine a “Landscape” like page.

In the file, go to the second sheet, and open FormatPrint RangesEdit. See that the print range is explicitly set to the $A$1:$E$45:

image

Use FormatPrint RangesClear to remove the limit.

Thank you, how to write the command line :grinning:
(Because it is on the Linux platform, I can only use the command line to operate)

There is no command line options to modify documents. You might want to write macros and use them (also from the command line) to edit documents.

How to write macros,is there a tutorial link? :grinning:

hello, I wrote a macro, but reported an error. Can you help me fix it

Sub ClearPrintRanges
  Dim document As Object
  document   = ThisComponent
  For i = 0 To document.Sheets.Count - 1
    Dim sheet As Object, style As Object
    sheet = document.Sheets(i)
    style = sheet.getPrintAreas()
    style.removeByIndex()
  Next
  document.close(true)
End Sub

style.removeByIndex() Error