Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
When you add a new sheet to a workbook, it contains the default Page Setup settings. There may be times when you need to transfer the settings (PageSetup) from one worksheet to another. This document explains how to copy Page Setup settings from one worksheet to another using Aspose.Cells APIs.
The following sample code illustrates how to copy Page Setup settings from one worksheet to another using the PageSetup.Copy() method. Please refer to the sample code and its console output for reference.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
Workbook wb;
wb.GetWorksheets().Add(u"TestSheet1");
wb.GetWorksheets().Add(u"TestSheet2");
Worksheet TestSheet1 = wb.GetWorksheets().Get(u"TestSheet1");
Worksheet TestSheet2 = wb.GetWorksheets().Get(u"TestSheet2");
TestSheet1.GetPageSetup().SetPaperSize(PaperSizeType::PaperA3ExtraTransverse);
std::cout << "Before Paper Size: " << static_cast<int>(TestSheet1.GetPageSetup().GetPaperSize()) << std::endl;
std::cout << "Before Paper Size: " << static_cast<int>(TestSheet2.GetPageSetup().GetPaperSize()) << std::endl;
std::cout << std::endl;
CopyOptions copyOptions;
TestSheet2.GetPageSetup().Copy(TestSheet1.GetPageSetup(), copyOptions);
std::cout << "After Paper Size: " << static_cast<int>(TestSheet1.GetPageSetup().GetPaperSize()) << std::endl;
std::cout << "After Paper Size: " << static_cast<int>(TestSheet2.GetPageSetup().GetPaperSize()) << std::endl;
std::cout << std::endl;
Aspose::Cells::Cleanup();
return 0;
}
Before Paper Size: PaperA3ExtraTransverse
Before Paper Size: PaperLetter
After Paper Size: PaperA3ExtraTransverse
After Paper Size: PaperA3ExtraTransverse
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.