Question

I've searched the API, Google, StackOverflow, etc. trying to find an answer to the following questions, but thus far, my quest has been disappointing. Is anyone out there able to help me out?

1) I'm attempting to use the set_page_view() option to default the worksheet to the "Page Break Preview". Unfortunately the CPAN page does not give me the valid parameters for this function. I've attempted using set_page_view('Page Break Preview'), but that gives me the "Page Layout" view instead.

2) In my script, I reference the set_h_pagebreaks() and set_v_pagebreaks to dynamically place the page-breaks as I write the excel sheet. This works wonderfully, however the worksheets will sometimes create default page-breaks as well. Is there any way to remove the default page breaks using this module?

Thanks for any help that you can provide!! I can provide some of my code-set if need be.

Was it helpful?

Solution

In relation to your questions:

  1. Page Break Preview isn't currently supported by Excel::Writer::XLSX.

  2. The Excel::Writer::XLSX module doesn't do anything to set default page breaks. These are probably set by Excel itself. If they are then Excel::Writer::XLSX doesn't have any facility to remove them.

OTHER TIPS

About your question : "Is there any way to remove the default page breaks using this module?"

I think I have the beggining of a solution for you ;)

(even if it was 5 years ago my response could help others so...)

I struggled with this too (had a vertical and horizontal automatic page brak, arg, so annoying!) but I've come to realize that like the office website say : "Microsoft Excel inserts automatic page breaks based on the paper size, margin settings, scale options, and the positions of any manual page breaks that you insert." (https://support.office.com/en-us/article/insert-move-or-delete-page-breaks-in-a-worksheet-ad3dc726-beec-4a4c-861f-ed640612bdc2?omkt=en-001&ui=en-US&rs=en-001&ad=US)

So, like this text say, your automatic page breaks depend on several factors. What is your scale for printing by example? what is your paper size? And so on...

Personnally, my problem was that I had a scale of 100% for a very wide and long excel document. So I just wrote a function that calculate the ideal scale to avoid an automatic vertical page break and my automatic horizontal page breaks disappeared.

Hope it's useful ^^


EDIT : Here's an example of code

#We put the horizontal page breaks at line 20, 40 and 60
worksheet.set_h_pagebreaks([20,40,60])
#We calculate the ideal scale according to your criterias
ideal_scale=pre_determined_number/width_of_all_columns
#We put a scale and then, Excel won't put some automatic breakline when we'll 
#finish to write the excel file
worksheet.set_print_scale(ideal_scale)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top