Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9127293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:15:00+00:00 2026-06-17T07:15:00+00:00

I am trying to export excel to pdf . I am using C#. I

  • 0

I am trying to export excel to pdf.
I am using C#.

I have a problem with ExportAsFixedFormat. My documents have print area (set in Excel application, they work if manual send to print). But it does not work in my program. I set param paramIgnorePrintAreas as false, it does not help.

public void createXls(){
    ApplicationClass excelApplication = new ApplicationClass();
    Workbook excelWorkBook = null;
    //Worksheet excelWorksheet = null;
    excelApplication.ScreenUpdating = false;
    excelApplication.Visible = false;

    string paramSourceBookPath = @"C:\Temp\Test.xlsx";
    object paramMissing = Type.Missing;
    string paramExportFilePath = @"C:\Temp\Test.pdf";
    XlFixedFormatType paramExportFormat = XlFixedFormatType.xlTypePDF;
    XlFixedFormatQuality paramExportQuality = XlFixedFormatQuality.xlQualityStandard;
    bool paramOpenAfterPublish = false;
    bool paramIncludeDocProps = true;
    bool paramIgnorePrintAreas = false;
    object paramFromPage = Type.Missing;
    object paramToPage = Type.Missing;
    try
    {
        // Open the source workbook.
        excelWorkBook = excelApplication.Workbooks.Open(paramSourceBookPath,
         false, paramMissing, paramMissing, paramMissing,
         paramMissing, paramMissing, paramMissing, paramMissing,
         paramMissing, paramMissing, paramMissing, paramMissing,
         paramMissing, paramMissing);

    // Save it in the target format.
        if (excelWorkBook != null)
        {
            Worksheet excelWorksheet = (Worksheet) excelWorkBook.ActiveSheet;
            excelWorksheet.ExportAsFixedFormat(paramExportFormat,
             paramExportFilePath, paramExportQuality,
             paramIncludeDocProps, paramIgnorePrintAreas, paramFromPage,
             paramToPage, paramOpenAfterPublish,
             paramMissing);
        }
    } catch (Exception ex)
    {
    //richTextBox1.Text=ex.Message.ToString();
    }
    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();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:15:01+00:00Added an answer on June 17, 2026 at 7:15 am

    Just try to set the print area again, before exporting:

    excelWorksheet.PageSetup.PrintArea = "Print_Area";
    

    I had a similar problem that was caused, I think, because it was an International version of Excel and this command fix the output format.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to export the content of mysql database to excel using
I'm trying to export an array of arrays to excel. I have it set
I have been trying to export the charts from Excel as an image file
I'm trying to export a record set into Excel but it seems to keep
I am trying to export data from database to an excel sheet, using php
I have a very simple question. I have been trying to export a set
I have a datagridview in c# that I'm trying to export to excel. I'm
I am trying to export an html table to excel using JavaScript. However I
I am trying to export a gridview's contents to excel. I have some code:
I have been trying to export some datagrids in Silverlight to excel, but have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.