Belirtilen çalışma sayfalarını PDF ye kaydetmek Node.js ve C++ kullanarak

Varsayılan olarak, Aspose.Cells bütün görünen çalışma sayfalarını bir PDF dosyasına kaydeder. PdfSaveOptions.getSheetSet() seçeneğiyle, belirli çalışma sayfalarını PDF’ye kaydedebilirsiniz. Örneğin, etkin çalışma sayfasını PDF’ye, tüm çalışma sayfalarını (görünen ve gizli çalışma sayfaları dahil) PDF’ye, özel çoklu çalışma sayfalarını PDF’ye kaydedebilirsiniz.

Etkin Çalışma Sayfasını PDF Olarak Kaydet

Sadece aktif sayfayı PDF’ye aktarmak istiyorsanız, bunu PdfSaveOptions.getSheetSet() seçeneğine SheetSet.getActive() geçirerek başarabilirsiniz.

Kaynak dosyanın aktif sayfası sheetset-example.xlsx dosyasındaki Sheet2 sayfasıdır.

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sheetset-example.xlsx");

// Open the template excel file
const workbook = new AsposeCells.Workbook(filePath);

// Set active sheet to output
const pdfSaveOptions = new AsposeCells.PdfSaveOptions();
pdfSaveOptions.setSheetSet(AsposeCells.SheetSet.getActive());

// Save the pdf file with PdfSaveOptions
workbook.save("output.pdf", pdfSaveOptions);

** Tüm Çalışma Sayfalarını PDF’ye Kaydet**

SheetSet.getVisible() çalışma kitabında görünür sayfaları, SheetSet.getAll() ise görünür ve gizli/görülemez sayfaları dahil olmak üzere tüm sayfaları gösterir. Tüm sayfaları PDF’ye aktarmak istiyorsanız, sadece SheetSet.getAll() ile PdfSaveOptions.getSheetSet() seçeneğine geçebilirsiniz.

Kaynak dosya sheetset-example.xlsx gizli Sheet3 sayfası dahil olmak üzere dört sayfayı içerir.

const AsposeCells = require("aspose.cells.node");
const path = require("path");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sheetset-example.xlsx");

// Open the template excel file
const workbook = new AsposeCells.Workbook(filePath);

// Set all sheets to output
const pdfSaveOptions = new AsposeCells.PdfSaveOptions();
pdfSaveOptions.setSheetSet(AsposeCells.SheetSet.getAll());

// Save the pdf file with PdfSaveOptions
workbook.save("output.pdf", pdfSaveOptions);

Belirtilen Çalışsayfalarını PDF olarak kaydet

İstenen / özelleştirilmiş çoklu sayfayı PDF’ye aktarmak istiyorsanız, bunu PdfSaveOptions.getSheetSet() seçeneğine birden çok sayfa dizisi geçirerek başarabilirsiniz.

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sheetset-example.xlsx");

// Open the template excel file
const workbook = new AsposeCells.Workbook(filePath);

// Set custom multiple sheets(Sheet1, Sheet3) to output
const sheetSet = new AsposeCells.SheetSet([0, 2]);
const pdfSaveOptions = new AsposeCells.PdfSaveOptions();
pdfSaveOptions.setSheetSet(sheetSet);

// Save the pdf file with PdfSaveOptions
workbook.save("output.pdf", pdfSaveOptions);

** Çalışma Sayfalarını PDF’ye Yeniden Sırala**

Kaynak dosyayı değiştirmeden sayfaları (örneğin tersine sıralı) PDF’ye yeniden sıralamak istiyorsanız, bunu PdfSaveOptions.getSheetSet() seçeneğine sıralanmış sayfa indeksleri geçirerek başarabilirsiniz.

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sheetset-example.xlsx");
// Open the template excel file
const wb = new AsposeCells.Workbook(filePath);

// Reorder sheets(Sheet1, Sheet2, Sheet3, Sheet4) to sheets(Sheet4, Sheet3, Sheet2, Sheet1)
const sheetSet = new AsposeCells.SheetSet([3, 2, 1, 0]);
const pdfSaveOptions = new AsposeCells.PdfSaveOptions();
pdfSaveOptions.setSheetSet(sheetSet);

// Save the pdf file with PdfSaveOptions
wb.save("output.pdf", pdfSaveOptions);