Excel in Pdf, Bild und andere Formate konvertieren

Excel-Arbeitsmappe in PDF konvertieren

PDF-Dateien werden weit verbreitet eingesetzt, um Dokumente zwischen Organisationen, Regierungsbereichen und Einzelpersonen auszutauschen. Es handelt sich um ein standardisiertes Dokumentenformat, und Softwareentwickler werden oft gebeten, eine Möglichkeit zu finden, Microsoft Excel-Dateien in PDF-Dokumente zu konvertieren.

Aspose.Cells unterstützt die Konvertierung von Excel-Dateien in PDF und gewährleistet dabei eine hohe visuelle Genauigkeit bei der Konvertierung.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Instantiate the Workbook object
// Open an Excel file
Workbook workbook = new Workbook("Book1.xlsx");
// Save the document in PDF format
workbook.Save("output.pdf");

Excel-Arbeitsmappe in JPG konvertieren

Aspose.Cells unterstützt die Konvertierung von Excel-Dateien in JPG. Das unten stehende Codebeispiel zeigt, wie man eine Arbeitsmappe als JPG speichert.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
//Convert workbook to JPG image.
book.Save("Image1.jpg");

Excel-Arbeitsmappe in Bild konvertieren

Aspose.Cells unterstützt die Konvertierung von Excel-Dateien in Bilder. Das unten stehende Codebeispiel zeigt, wie man eine Arbeitsmappe als Bilder speichert.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
//Convert workbook to BMP image.
book.Save("Image1.bmp");
//Convert workbook to JPG image.
book.Save("Image1.jpg");
//Convert workbook to Png image.
book.Save("Image1.png");
//Convert workbook to EMF image.
book.Save("Image1.emf");
//Convert workbook to GIF image.
book.Save("Image1.gif");

Excel-Arbeitsmappe in XPS konvertieren

Das XPS-Dokumentenformat besteht aus strukturierter XML-Auszeichnung, die das Layout eines Dokuments und das visuelle Erscheinungsbild jeder Seite sowie Rendering-Regeln zur Verteilung, Archivierung, Darstellung, Verarbeitung und zum Drucken von Dokumenten definiert.

Die Auszeichnungssprache für XPS ist ein Subset von XAML, das es ermöglicht, Vektorgrafikelemente in Dokumente zu integrieren, indem XAML die Windows Presentation Foundation (WPF)-Primitive markiert. Die verwendeten Elemente werden in Bezug auf Pfade und andere geometrische Primitiven beschrieben.

Eine XPS-Datei ist tatsächlich ein Unicode-ZIP-Archiv, das die Open Packaging Conventions verwendet und die Dateien enthält, aus denen das Dokument besteht. Dazu gehören eine XML-Auszeichnungsdatei für jede Seite, Text, eingebettete Schriften, Rasterbilder, 2D-Vektorgrafiken sowie die Informationen zum Digital Rights Management. Der Inhalt einer XPS-Datei kann einfach untersucht werden, indem sie in einer Anwendung geöffnet wird, die ZIP-Dateien unterstützt.

Ab Aspose.Cells 6.0.0 wird die Konvertierung von Microsoft Excel in XPS unterstützt.

// 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);
// Open an Excel file
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(dataDir + "Book1.xls");
// Get the first worksheet
Aspose.Cells.Worksheet sheet = workbook.Worksheets[0];
// Apply different Image and Print options
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
// Set the Format
options.SaveFormat = SaveFormat.Xps;
// Render the sheet with respect to specified printing options
Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(sheet, options);
// Save
sr.ToImage(0, dataDir + "out_printingxps.out.xps");
// Export the whole workbook to XPS
workbook.Save(dataDir + "out_whole_printingxps.out.xps", new XpsSaveOptions());

Excel in Ods, Sxc und Fods (OpenOffice / LibreOffice Calc) konvertieren

Aspose.Cells unterstützt die Konvertierung von Excel-Dateien in Ods-, Sxc- und Fods-Dateien. Das nachstehende Codebeispiel zeigt, wie man die Vorlage in Ods-, Sxc- und Fods-Dateien konvertiert.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("book1.xlsx");
// Save as ods file
workbook.Save("Out.ods");
// Save as sxc file
workbook.Save("Out.sxc");
// Save as fods file
workbook.Save("Out.fods");

Excel-Arbeitsmappe in MHTML-Dateien konvertieren

MHTML kombiniert normales HTML mit externen Ressourcen (das heißt, Inhalt, der normalerweise verknüpft ist, wie Bilder, Animationen, Audio usw.) in einer Datei. Sie werden für E-Mails mit der Dateierweiterung .mht verwendet.

Aspose.Cells unterstützt das Lesen und Schreiben von MHTML-Dateien.

Das unten stehende Codebeispiel zeigt, wie man eine Arbeitsmappe als MHTML-Datei speichert.

// 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);
// Specify the file path
string filePath = dataDir + "Book1.xlsx";
// Specify the HTML Saving Options
HtmlSaveOptions sv = new HtmlSaveOptions(SaveFormat.MHtml);
// Instantiate a workbook and open the template XLSX file
Workbook wb = new Workbook(filePath);
// Save the MHT file
wb.Save(filePath + ".out.mht", sv);

Excel-Arbeitsmappe in HTML konvertieren

Die Aspose.Cells-API bietet Unterstützung für den Export von Tabellenkalkulationen im HTML-Format. Hierfür verwendet Aspose.Cells die Klasse HtmlSaveOptions, um die Flexibilität zu bieten, verschiedene Aspekte der Ausgabe-HTML zu steuern.

Das folgende Beispiel zeigt, wie man eine Arbeitsmappe als HTML-Datei speichert.

// 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);
// Specify the file path
string filePath = dataDir + "sample.xlsx";
// Load your sample excel file in a workbook object
Workbook wb = new Workbook(filePath);
// Save it in HTML format
wb.Save(dataDir + "ConvertingToHTMLFiles_out.html", SaveFormat.Html);

Bildvoreinstellungen für HTML einstellen

Ab Windows 8.0.2 hat Aspose.Cells ImageOptions für die Klasse HtmlSaveOptions freigelegt, was es Entwicklern ermöglicht, Bildpräferenzen beim Speichern von Tabellenkalkulationen im HTML-Format anzugeben.

Im Folgenden sind Details einiger Bildvoreinstellungen aufgelistet,

  • ImageType: Gibt den Bildtyp an. Bitte beachten Sie, dass alle Formen, einschließlich Diagramme, im Ausgabe-HTML als Bilder gerendert werden.
  • SmoothingMode: Gibt das Anti-Aliasing für Linien, Kurven und Kanten von gefüllten Bereichen an.
  • TextRenderingHint: Gibt die Qualität der Textdarstellung an.
  • Quality: Gibt die Qualität des Bildes zwischen 0 und 100 an, wenn ImageType als Jpeg angegeben ist.
  • VerticalResolution: Ruft die vertikale Auflösung des Bildes in Punkten pro Zoll ab oder legt diese fest.
  • HorizontalResolution: Ruft die horizontale Auflösung des Bildes in Punkten pro Zoll ab oder legt diese fest.
  • TiffCompression: Ruft den Kompressionstyp für die Bilder ab oder legt diesen fest, wenn ImageType als Tiff angegeben ist.
  • Transparent: Gibt an, ob der Hintergrund eines Bildes transparent sein soll, wenn ImageFormat als Png angegeben ist.

Der folgende Code demonstriert, wie HtmlSaveOptions.ImageOptions verwendet wird, um verschiedene Präferenzen anzugeben.

// 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);
// Specify the file path
string filePath = dataDir + "Book1.xlsx";
// Load a spreadsheet to be converted
Workbook book = new Workbook(filePath);
// Create an instance of HtmlSaveOptions
HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.Html);
// Set the ImageFormat to PNG
saveOptions.ImageOptions.ImageType = Drawing.ImageType.Png;
// Set SmoothingMode to AntiAlias
saveOptions.ImageOptions.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
// Set TextRenderingHint to AntiAlias
saveOptions.ImageOptions.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
// Save spreadsheet to HTML while passing object of HtmlSaveOptions
book.Save( dataDir + "output.html", saveOptions);

Excel-Arbeitsmappe in Markdown konvertieren

Die Aspose.Cells-API bietet Unterstützung für den Export von Tabellenkalkulationen im Markdown-Format. Um das aktive Arbeitsblatt in Markdown zu exportieren, geben Sie SaveFormat.Markdown als zweiten Parameter der Methode Workbook.Save weiter. Sie können auch die Klasse MarkdownSaveOptions verwenden, um zusätzliche Einstellungen für den Export des Arbeitsblattes in Markdown anzugeben.

Das folgende Codebeispiel demonstriert den Export des aktiven Arbeitsblatts in Markdown unter Verwendung des Enumerationselements SaveFormat.Markdown. Bitte beachten Sie die Ausgabedatei im Markdown-Format, die vom Code generiert wurde, als Referenz.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open the template file
Workbook workbook = new Workbook(sourceDir + "Book1.xlsx");
// Save as Markdown
workbook.Save(outputDir + "Book1.md", SaveFormat.Markdown);

Excel-Arbeitsmappe in JSON konvertieren

Aspose.Cells unterstützt die Konvertierung einer Arbeitsmappe in eine Json(Javascript Object Notation)-Datei.

Das folgende Beispiel demonstriert, wie das aktive Arbeitsblatt in JSON exportiert wird, indem das SaveFormat.Json Enumerationsmitglied verwendet wird. Bitte sehen Sie den Code zur Konvertierung der Quelldatei in die erstellte JSON-Datei für Referenzzwecke an.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx");
// convert the workbook to json file.
workbook.Save(dir + "book1.json");

Excel in XML umwandeln

Aspose.Cells unterstützt die Konvertierung einer Arbeitsmappe in das Excel 2003 Spreadsheet XML- und das Plain-XML-Format.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Load your source workbook
Workbook workbook = new Workbook("Book1.xlsx");
//Save as Excel 2003 Spreadsheet XML
workbook.Save("Spreadsheet.xml");
//Save as plain XML data
XmlSaveOptions xmlSaveOptions = new XmlSaveOptions();
workbook.Save("data.xml", xmlSaveOptions);

Excel-Arbeitsmappe in TIFF umwandeln

Aspose.Cells unterstützt die Konvertierung einer Arbeitsmappe in eine TIFF-Datei.

Der unten stehende Codeausschnitt zeigt, wie Excel in TIFF umgewandelt wird:

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open a template excel file
Workbook book = new Workbook("Book1.xlsx");
//save file to tiff
book.Save("out.tiff");

Excel-Arbeitsmappe in DOCX umwandeln

Die Aspose.Cells-API bietet Unterstützung für die Konvertierung von Tabellenkalkulationen in das DOCX-Format. Um die Arbeitsmappe in DOCX zu exportieren, geben Sie als zweiten Parameter der Methode Workbook.Save das SaveFormat.Docx an. Sie können auch die DocxSaveOptions-Klasse verwenden, um zusätzliche Einstellungen für den Export des Arbeitsblatts in DOCX festzulegen.

Das folgende Codebeispiel zeigt, wie das aktive Arbeitsblatt in DOCX exportiert wird, indem das Element SaveFormat.Docx verwendet wird. Sehen Sie sich die Ausgabe-DOCX-Datei an, die vom Code generiert wurde, um sich zu orientieren.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open the template file
Workbook workbook = new Workbook(sourceDir + "Book1.xlsx");
// Save as Markdown
workbook.Save(outputDir + "Book1.docx", SaveFormat.Docx);

Excel-Arbeitsmappe in PPTX umwandeln

Die Aspose.Cells-API bietet Unterstützung für die Konvertierung von Tabellenkalkulationen in das PPTX-Format. Um die Arbeitsmappe in PPTX zu exportieren, geben Sie als zweiten Parameter der Methode Workbook.Save das SaveFormat.Pptx an. Sie können auch die PptxSaveOptions-Klasse verwenden, um zusätzliche Einstellungen für den Export des Arbeitsblatts in PPTX festzulegen.

Das folgende Codebeispiel zeigt, wie das aktive Arbeitsblatt in PPTX exportiert wird, indem das Element SaveFormat.Pptx verwendet wird. Sehen Sie sich die Ausgabe-PPTX-Datei an, die vom Code generiert wurde, um sich zu orientieren.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Open the template file
Workbook workbook = new Workbook(sourceDir + "Book1.xlsx");
// Save as Markdown
workbook.Save(outputDir + "Book1.pptx", SaveFormat.Pptx);

Erweiterte Themen