Page 1 of 1

[Solved] Draw Border To Multiple Sheets at the same time

PostPosted: Mon Nov 11, 2019 10:37 am
by npandit
I have been using this line to get a specific sheet to work with it
oSheet = oDoc.getSheets().getByIndex(0)
With the above line it draws border only to specified index sheet
But I want to use multiple sheets to draw border at the same time
How to do that ?

Re: To Draw Border To Multiple Sheets at the same time

PostPosted: Mon Nov 11, 2019 12:57 pm
by musikai
Hi,

either you specify which sheets you want by changing the last number:
Code: Select all   Expand viewCollapse view
oDoc=ThisComponent
oSheet = oDoc.getSheets().getByIndex(0)
rem  do something
oSheet = oDoc.getSheets().getByIndex(1)
rem  do something


Or you can change all one by one:
Code: Select all   Expand viewCollapse view
oDoc=ThisComponent
for i=0 to oDoc.getsheets().count-1
oSheet = oDoc.getsheets().getbyindex(i)
rem  do something
next i

Re: To Draw Border To Multiple Sheets at the same time

PostPosted: Mon Nov 11, 2019 1:04 pm
by Villeroy
This is what templates are about. All office suites are mainly about templates. Generating new documents by means of program code is stupid even if you were able to program.

Re: To Draw Border To Multiple Sheets at the same time

PostPosted: Tue Nov 19, 2019 7:17 am
by npandit
Hey
Thanks the For Loop worked .
But its applying border to all sheets now
I want to apply border from 2nd sheet till so on
i dont want border on the first sheet.
Can u please suggest code to apply border for all sheets except the first sheet?

Re: To Draw Border To Multiple Sheets at the same time

PostPosted: Tue Nov 19, 2019 7:27 am
by Zizi64
If you are a programmer, you must know the solution method.

Just start the Loop from 1 instead of the 0

Or you can apply a different Style to the first Sheet. Always work with styles instead of the direct formatting properties!
The Styles is the most valable property of the AOO/LO.

Or simple open a preformatted Template by your program code, - as Villeroy suggested. Use the Styles for the formating the Template.

Re: To Draw Border To Multiple Sheets at the same time

PostPosted: Tue Nov 19, 2019 8:04 am
by npandit
Thanks ZiZi
Thanks for the help means a lot
We all are learners here :)