-1

i am currently utilizing GemBox.Spreadsheet as a plugin for my C# App. what i want to achieve at the moment is to print the Excel file in a different paper size (let's say A6 for example).

i've found in the documentation about .PaperType in GemBox.Spreadsheet.ExcelPrintOptions but i can't seem to access it properly, accessing it via:

var x = new GemBox.Spreadsheet.ExcelPrintOptions().PaperType = GemBox.Spreadsheet.PaperType.A6;

gives me an error that says, "'ExcelPrintOptions' does not contain a contructor that takes 0 arguments"

is there any other way i can achieve this or am i doing it the wrong way.

i am printing an existing excel file via:

GemBox.Spreadsheet.ExcelFile.Load(string.Format(@"{0}\{1}.xlsx", Path.GetTempPath(), HashName)).Print();
TheQuestioner
  • 702
  • 10
  • 28

1 Answers1

1

Use the following:

var workbook = ExcelFile.Load(
    string.Format(@"{0}\{1}.xlsx", Path.GetTempPath(), HashName));

var worksheet = workbook.Worksheets.ActiveWorksheet;
worksheet.PrintOptions.PaperType = PaperType.A6;

var printOptions = new PrintOptions() { SelectionType = SelectionType.ActiveSheet };
workbook.Print(null, printOptions);
Mario Z
  • 4,328
  • 2
  • 24
  • 38