Excel print not comig properly

Hi,

Thanks for your feedback and illustration.

I can notice the issue with your file, we will investigate how this issue could be be resolved.

Once, we have some update for you, we will let you know asap.

Below is a screenshot for a reference.

Screenshot:

Hi,

To further help you understand the difference in this implementation(from earlier example).

AllQuestions-TopBox(25-06-2012)(11).xls contain 3 spreadsheets
1) Visual Report
2) Sample size 3) Top Box %

Visual Report picks up data from 2) and 3) spreadsheets but even when data is not there in pdf page 2, it is showing 257 pages(Screen1.jpg)

Below lines does not give appropriate solution as shown in the earlier conversation screenshot.
ws.PageSetup.FitToPagesWide = 1 and ws.PageSetup.FitToPagesTall = 0

code :–

ws.HorizontalPageBreaks.Clear();
ws.VerticalPageBreaks.Clear();

ws.PageSetup.PrintArea = null;

//Aspose.Cells.Style styles = new Aspose.Cells.Style();
//styles.IsTextWrapped = true;
//Aspose.Cells.StyleFlag sfalgs = new Aspose.Cells.StyleFlag();
//sfalgs.WrapText = true;
//ws.Cells.ApplyStyle(styles, sfalgs);
ws.Cells.SetColumnWidth(0, 30);

//ws.PageSetup.FitToPagesWide = 1;
//ws.PageSetup.FitToPagesTall = 0;

ws.AutoFitRows();

Thanks,
Nagamani


Hi,


Well, Aspose.Cells does nothing more than what MS Excel can do regarding fitting pages wide/tall and other page setup options. It has to follow the MS Excel restrictions as after all, MS Excel will display the Excel (generated by Aspose.Cells component) file and what you will see in the print preview, MS Excel will print it accordingly. We still think as Shakeel Faiz has described, there might be an issue with your template file and so Aspose.Cells cannot do according to your desired needs. Anyways, we have further logged your further comments and one of our main developer will look into it soon.

We highly appreciate if you could format your template file regarding fitting pages tall/wide and other page setup options (and Save it as) accordingly in MS Excel manually. Please take your template file “AllQuestions-TopBox(25-06-2012)(8).xls” that you previously attached, open it in MS Excel and do your desired formatting regarding fitting pages tall/wide and use other page setup options manually. Now save the file and attach it here. We will give you example codes on how to do it using Aspose.Cells. For your information, I have already tried to do some page setup and other row/column formatting options in MS Excel manually but in vain as I could not make the first sheet wide enough to show all the columns no matter how many pages are created (fit to pages tall). So, I would ask you to kindly try the options in MS Excel manually and formulate according to your needs to share the final Excel file here. We will surely check it soon.

By the way, how did you create/get the template file?

Thank you.

Hi,

Thanks for using Aspose.Cells

Please note, your issue has been logged with the id: CELLSNET-40782

We will look into your problem and update you asap.

Hi,

The cells in the range A11:DS685 are not empty. If you do not set the print area, the default pint area is A1: DS685, so the print preview is very small when you want to print so many columns to one page.

If you just want to print the area with data, please try the following code:

I have attached the screenshot for your reference.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\AllQuestions-TopBox(25-06-2012)(11).xls”;


Workbook workbook = new Workbook(filePath);

Cells cell = workbook.Worksheets[“Visual Report”].Cells;


string pArea = “A1:” + CellsHelper.CellIndexToName(workbook.Worksheets[“Top Box %”].Cells.MaxRow, workbook.Worksheets[“Top Box %”].Cells.MaxColumn);


workbook.Worksheets[“Visual Report”].PageSetup.PrintArea = pArea;


workbook.Save(filePath + “.out.xls”);

Screenshot:

Hi Team,

Thanks for your reply.Few things we have noticed is

1.The screen shots which you have attached is not the desired output format ,We want all the columns in a single page, but in the screen shots which you have provided 2 columns are in one page and next 4 columns are in another page.

2.We have tried the solution which you have suggested us.But the out put is still same,except for PrintArea added extra at the end of “Visual Report”.Thus results in duplicate data.Please find the attached file.

Thanks
Nagamani.

Hi,


It works fine using the code segments shared earlier. I have tested it using your file “AllQuestions-TopBox(26-06-2012)(10).xls” as template/input file and apply the code segments to generate the output file according to your needs, see the output file and take the print preview for your reference, it works according to your needs.

Sample code:

string filePath = @“e:\test2\AllQuestions-TopBox(26-06-2012)(10).xls”;
Workbook workbook = new Workbook(filePath);
Cells cell = workbook.Worksheets[“Visual Report”].Cells;
//Since your details data starts from 9th row, so I have added 8 to the row count while specifying the cell area for the first row.
string pArea = “A1:” + CellsHelper.CellIndexToName(workbook.Worksheets[“Top Box %”].Cells.MaxDataRow + 9, workbook.Worksheets[“Top Box %”].Cells.MaxDataColumn);
workbook.Worksheets[“Visual Report”].PageSetup.PrintArea = pArea;
workbook.Worksheets[“Visual Report”].PageSetup.FitToPagesWide = 1;
workbook.Worksheets[“Visual Report”].PageSetup.FitToPagesWide = 0;
workbook.Save(filePath + “.out2.xls”);

Thank you.