حفظ كل ورقة عمل إلى ملف PDF مختلف باستخدام Node.js عبر C++

حفظ كل ورقة عمل في ملف PDF مختلف

إذا كنت بحاجة إلى حفظ كل ورقة عمل في ملف Excel الخاص بك لإنشاء ملفات PDF مختلفة، يمكنك تحقيق ذلك بسهولة. يمكنك محاولة تعيين فهرس ورقة واحدة إلى [PdfSaveOptions.SheetSet](https://reference.aspose.com/cells/nodejs-cpp/pdfs saveoptions/#sheetSet) على حدة لعرضها كـ PDF.

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

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
// Get the Excel file path
const filePath = path.join(dataDir, "input.xlsx");

// Instantiate a new workbook and open the Excel file from its location
const workbook = new AsposeCells.Workbook(filePath);

// Get the count of the worksheets in the workbook
const sheetCount = workbook.getWorksheets().getCount();

// Define PdfSaveOptions
const pdfSaveOptions = new AsposeCells.PdfSaveOptions();

// Take PDFs of each sheet
for (let j = 0; j < sheetCount; j++) {
const ws = workbook.getWorksheets().get(j);

// set worksheet to output
const sheetSet = new AsposeCells.SheetSet([ws.getIndex()]);
pdfSaveOptions.setSheetSet(sheetSet);

workbook.save(path.join(dataDir, `worksheet-${ws.getName()}.out.pdf`), pdfSaveOptions);
}