Guarde cada hoja de trabajo en un archivo PDF diferente
Contents
[
Hide
]
Aspose.Cells admite la conversión de archivos XLS (que contienen imágenes, gráficos, etc.) a documentos PDF. Aspose.Cells for .NET puede funcionar de forma independiente para convertir una hoja de cálculo a PDF y no necesita usar Aspose.PDF for .NET para la conversión. La conversión no requiere que el software cree o use ningún archivo temporal, ya que todo el proceso se puede realizar en la memoria.
Guarde cada hoja de trabajo en un archivo PDF diferente
Si necesita guardar cada hoja de trabajo en su archivo de plantilla de Excel para generar diferentes archivos PDF, puede lograrlo fácilmente. Puede intentar ocultar hojas en el archivo y hacer que una hoja sea visible a la vez para mostrarla en PDF.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Get the Excel file path | |
string filePath = dataDir + "input.xlsx"; | |
// Instantiage a new workbook and open the Excel, File from its location | |
Workbook workbook = new Workbook(filePath); | |
// Get the count of the worksheets in the workbook | |
int sheetCount = workbook.Worksheets.Count; | |
// Define PdfSaveOptions | |
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); | |
// Take Pdfs of each sheet | |
for (int j = 0; j < sheetCount; j++) | |
{ | |
Worksheet ws = workbook.Worksheets[j]; | |
//set worksheet to output | |
SheetSet sheetSet = new SheetSet(new int[] { ws.Index }); | |
pdfSaveOptions.SheetSet = sheetSet; | |
workbook.Save(dataDir + "worksheet-" + ws.Name + ".out.pdf", pdfSaveOptions); | |
} |
Si su hoja de cálculo contiene fórmulas, es mejor llamarLibro de trabajo. Calcular fórmula ()justo antes de renderizar la hoja de cálculo al formato PDF. Si lo hace, se asegurará de que los valores dependientes de la fórmula se vuelvan a calcular y los valores correctos se representen en el PDF.