Hello. Thank you for your help.
An example of excel with that I work I attach it in this message.
The workbook has two worksheets: Report and Informe. Report contains the information and Informe contains links and formula on the above mentioned information. I need to print only Informe worksheets.
I have several doubts:
1. If my Informe worksheet has areas of impression definite, why on having done
Workbook workbook = new Workbook ();
Workbook. Open ("C:\example.xls");
Workbook. Worksheets ["Informe"] .SheetToPrinter ("Microsoft Office Document Image Writer");
It does not appear well?
I have used Microsoft Office Document Image Writer, PDFCreator, ... (virtual printers PDF) to print pdf of tests.
2. I need to print on an alone document (with several pages) the Informe worksheet. I have tried to define the following :
PageSetup pageSetup = workbook. Worksheets ["Informe"] .PageSetup;
PageSetup. Orientation = PageOrientationType. Landscape;
PageSetup. Zoom = 11;
PageSetup. PrintArea = "A1:U58, A121:X177, A178:X236, A237:X297 ";
PageSetup. FitToPagesWide = 1;
PageSetup. FitToPagesTall = 1;
But in the instruction next:
workbook.Worksheets["Informe"].SheetToPrinter("Microsoft Office Document Image Writer");
a mistake takes is produced of "invalid cell name".
In addition if only I use the option:
PageSetup. PrintArea = "A1:U58";
landscope it does not work, and the document does not appear correctly.
3. Also I am proving the component aspose.pdf.
In the same way that exists the instructions:
workbook.Worksheets ["Informe"].SheetToPrinter ("Microsoft Office Document Image Writer");
Why do not I have an instruction that selected worksheets guards in format pdf? Something as this:
workbook.Worksheets ["Informe"].Save(@"C:\MySpreadsheet.xml", FileFormatType.AsposePdf);
Aspose.Pdf.Pdf pdf1 = new Aspose.Pdf.Pdf();
//Bind the XML file (containing spreadsheet data) with the Pdf object
pdf1.BindXML(@"C:\MySpreadsheet.xml", null);
//Create the PDF document by calling its Save method
pdf1.Save(@"C:\MySpreadsheet.pdf");
I only need to print one worksheets. Then I need to select only Informe worksheets:
Workbook singleSheet = new Workbook();
for (int rowIndex = 0; rowIndex <= workbook.Worksheets["Informe"].Cells.MaxRow; rowIndex++)
{
for (int colIndex = 0; colIndex <= workbook.Worksheets["Informe"].Cells.MaxColumn; colIndex++)
{
object objValue = workbook.Worksheets["Informe"].Cells[rowIndex, colIndex].Value;
Aspose.Cells.Style objStyle = workbook.Worksheets["Informe"].Cells[rowIndex, colIndex].GetStyle();
singleSheet.Worksheets[0].Cells[rowIndex, colIndex].SetStyle(objStyle);
singleSheet.Worksheets[0].Cells[rowIndex, colIndex].PutValue(objValue);
}
}
singleSheet.Save(@"C:\MySpreadsheetsingle.xls");
//// Save the document in Aspose.Pdf.Xml format
singleSheet.Save(@"C:\MySpreadsheet.xml", FileFormatType.AsposePdf);
I need to copy data and style, and this, to part of that does not work well, it consumes a lot of time. Then to generate a pdf consumes a lot of time because I have to remain alone with a worksheet and then to print it.
Can you help me, please? Is very important.
Thanks you.