Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Sometimes, you need to know the width and height of a paper size as set in the page setup of the worksheet. Please use the GetPaperWidth() and GetPaperHeight() methods for this purpose.
The following sample code demonstrates the usage of GetPaperWidth() and GetPaperHeight() methods. It first changes the paper size to A2 and prints the width and height of the paper, then changes it to A3, A4, and Letter, printing the corresponding dimensions each time.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
using namespace std;
int main()
{
Aspose::Cells::Startup();
// Create an instance of Workbook class
Workbook book;
// Access first worksheet
Worksheet sheet = book.GetWorksheets().Get(0);
// Set paper size to A2 and print paper width and height in inches
sheet.GetPageSetup().SetPaperSize(PaperSizeType::PaperA2);
cout << "PaperA2: " << sheet.GetPageSetup().GetPaperWidth() << "x" << sheet.GetPageSetup().GetPaperHeight() << endl;
// Set paper size to A3 and print paper width and height in inches
sheet.GetPageSetup().SetPaperSize(PaperSizeType::PaperA3);
cout << "PaperA3: " << sheet.GetPageSetup().GetPaperWidth() << "x" << sheet.GetPageSetup().GetPaperHeight() << endl;
// Set paper size to A4 and print paper width and height in inches
sheet.GetPageSetup().SetPaperSize(PaperSizeType::PaperA4);
cout << "PaperA4: " << sheet.GetPageSetup().GetPaperWidth() << "x" << sheet.GetPageSetup().GetPaperHeight() << endl;
// Set paper size to Letter and print paper width and height in inches
sheet.GetPageSetup().SetPaperSize(PaperSizeType::PaperLetter);
cout << "PaperLetter: " << sheet.GetPageSetup().GetPaperWidth() << "x" << sheet.GetPageSetup().GetPaperHeight() << endl;
Aspose::Cells::Cleanup();
return 0;
}
Here is the console output of the above sample code.
PaperA2: 16.54x23.39
PaperA3: 11.69x16.54
PaperA4: 8.27x11.69
PaperLetter: 8.5x11
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.