I wrote a program that creates an excel file and at the end of that file, it creates a chart from that data.
Then I export that file to pdf via ExportAsFixedFormat method but it just exports that chart to pdf.
How can I export the whole page to pdf?
(I use Office 2007)
Thanks

Majid KamaliPosted Oct 21, 2011, 1:09 AM
I should activate a arbitrary cell before exporting to pdf. because chart must be unselected.
before my code, I used this:
(myWorkSeet.Cells[1,1] as Excel.Range).Activate();
Javeed M ShaikhPosted Oct 20, 2011, 3:59 PM
Please check if you are doing the same steps like below:
string paramSourceBookPath = @"C:\MyExcel.xlsx";
object paramMissing = Type.Missing;
string paramExportFilePath = @"C:\MyTestPdf.pdf";
XlFixedFormatType paramExportFormat = XlFixedFormatType.xlTypePDF;
XlFixedFormatQuality paramExportQuality =
XlFixedFormatQuality.xlQualityStandard;
bool paramOpenAfterPublish = false;
bool paramIncludeDocProps = true;
bool paramIgnorePrintAreas = true;
object paramFromPage = Type.Missing;
object paramToPage = Type.Missing;
try
{
// Open the source workbook.
excelWorkBook = excelApplication.Workbooks.Open(paramSourceBookPath,
paramMissing, paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing);
// Save it in the target format.
if (excelWorkBook != null)
excelWorkBook.ExportAsFixedFormat(paramExportFormat,
paramExportFilePath, paramExportQuality,
paramIncludeDocProps, paramIgnorePrintAreas, paramFromPage,
paramToPage, paramOpenAfterPublish,
paramMissing);
}
catch (Exception ex)
{
// Respond to the error.
}
finally
{
// Close the workbook object.
if (excelWorkBook != null)
{
excelWorkBook.Close(false, paramMissing, paramMissing);
excelWorkBook = null;
}
// Quit Excel and release the ApplicationClass object.
if (excelApplication != null)
{
excelApplication.Quit();
excelApplication = null;
}
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
}
Please do not forget to mark "Accepted Answer".
Majid KamaliPosted Oct 20, 2011, 2:33 PM
I want to create a pdf from an existing excel file.
Also I do not have enough time to learn iTextSharp.
Please help.
Suthish NairPosted Oct 20, 2011, 1:14 PM