Utilizzando Aspose.Total for .NET puoi convertire facilmente file CGM in TXT all’interno di qualsiasi applicazione .NET, C#, ASP.NET e VB.NET. Innanzitutto, utilizzando Aspose.PDF for .NET , puoi esportare CGM in XLSX. Successivamente, utilizzando l’API di programmazione per fogli di calcolo Aspose.Cells for .NET , è possibile convertire XLSX in TXT.
API .NET per convertire CGM in TXT
Requisiti di conversione
Installa dalla riga di comando come nuget install Aspose.Total
o tramite Package Manager Console di Visual Studio con Install-Package Aspose.Total
.
In alternativa, scarica il programma di installazione MSI offline o le DLL in un file ZIP da downloads .
// supports PDF, CGM, EPUB, TeX, PCL, PS, SVG, XPS, MD, MHTML, XML, and XSLFO file format | |
// load PDF as input file format with an instance of Document class | |
var document = new Document("template.pdf"); | |
// save document in XLSX format | |
document.Save("excel_output.xlsx", Aspose.Pdf.SaveFormat.Xlsx); | |
// load the XLSX file in an instance of Workbook | |
var book = new Workbook("excel_output.xlsx"); | |
// supports XLSB, XLSM, XLT, XLTX, XLTM, XLAM, CSV, TSV, TXT, ODS, DIF, MD, SXC, and FODS file format | |
// save input document as CSV | |
book.Save("output.csv", Aspose.Cells.SaveFormat.Auto); |
Converti CGM protetto in TXT tramite C#
Se il tuo documento CGM è protetto da password, non puoi convertirlo in TXT senza la password. Usando l’API, puoi prima aprire il documento protetto usando una password valida e poi convertirlo. Per aprire il file crittografato, è possibile inizializzare una nuova istanza della classe Document e passare il nome file e la password come argomenti.
// supports PDF, CGM, EPUB, TeX, PCL, PS, SVG, XPS, MD, MHTML, XML, and XSLFO input file formats | |
// open password protected PDF document | |
Document doc = new Document("input.pdf", "Your@Password"); | |
// save document in XLSX format | |
document.Save("excel_output.xlsx", Aspose.Pdf.SaveFormat.Xlsx); | |
// load the XLSX file in an instance of Workbook | |
var book = new Workbook("excel_output.xlsx"); | |
// supports XLSB, XLSM, XLT, XLTX, XLTM, XLAM, CSV, TSV, TXT, ODS, DIF, MD, SXC, and FODS file format | |
// save input document as CSV | |
book.Save("output.csv", Aspose.Cells.SaveFormat.Auto); |
Converti file CGM in TXT con filigrana tramite C#
Durante la conversione del file CGM in TXT, puoi anche aggiungere una filigrana al formato del file TXT di output. Per aggiungere una filigrana, puoi creare un nuovo oggetto Cartella di lavoro e aprire il documento XLSX convertito, selezionare Foglio di lavoro tramite il suo indice, creare una forma e utilizzare la sua funzione AddTextEffect. Successivamente puoi salvare il tuo documento XLSX come TXT con Watermark.
// supports PDF, CGM, EPUB, TeX, PCL, PS, SVG, XPS, MD, MHTML, XML, and XSLFO file format | |
// load PDF as input file format with an instance of Document class | |
var document = new Document("template.pdf"); | |
// save document in XLSX format | |
document.Save("excel_output.xlsx", Aspose.Pdf.SaveFormat.Xlsx); | |
// load the XLSX file in an instance of Workbook | |
var book = new Workbook("excel_output.xlsx"); | |
// get the first default sheet | |
var sheet = book.Worksheets[0]; | |
// add a new shape to ShapesCollection of Worksheet | |
var wordart = sheet.Shapes.AddTextEffect(Aspose.Cells.Drawing.MsoPresetTextEffect.TextEffect1, | |
"CONFIDENTIAL", "Arial Black", 50, false, true, 18, 8, 1, 1, 130, 800); | |
// supports XLSB, XLSM, XLT, XLTX, XLTM, XLAM, CSV, TSV, TXT, ODS, DIF, MD, SXC, and FODS file format | |
// save input document as CSV | |
book.Save("output.csv", Aspose.Cells.SaveFormat.Auto); |