En utilisant Aspose.Total for Java , vous pouvez intégrer la fonction de conversion SVG vers XLTX dans vos applications Java en deux étapes. Tout d’abord, en utilisant Aspose.PDF for Java , vous pouvez rendre SVG en XLSX. Dans la deuxième étape, vous pouvez convertir XLSX en XLTX à l’aide de l’API de programmation de feuille de calcul Aspose.Cells for Java .
Convertir le fichier SVG en XLTX via Java
- Ouvrez le fichier SVG à l’aide de la classe Document
- Convertissez SVG en XLSX en utilisant save méthode
- Chargez le document XLSX à l’aide de la classe Workbook
- Enregistrez le document au format XLTX en utilisant [save]( https://reference.aspose.com/cells/java/com.aspose.cells/workbook#save(java.lang.String,%20com.aspose.cells . Méthode SaveOptions))
Exigences de conversion
Vous pouvez facilement utiliser Aspose.Total pour Java directement à partir d’un projet basé sur Maven pdf/java/installation/) et Aspose.Cells for Java dans votre pom.xml.
// supports PDF, CGM, EPUB, TeX, PCL, PS, SVG, XPS, MD, MHTML, XML, and XSLFO file format | |
// load PDF with an instance of Document | |
Document document = new Document("template.pdf"); | |
// save document in XLSX format | |
document.save("XlsxOutput.xlsx", SaveFormat.Xlsx); | |
// load the XLSX file in an instance of Workbook | |
Workbook book = new Workbook("XlsxOutput.xlsx"); | |
// supports CSV, XLSB, XLSM, XLT, XLTX, XLTM, XLAM, TSV, TXT, ODS, DIF, MD, SXC, and FODS file format | |
// save XLSX as CSV | |
book.save("output.csv", SaveFormat.AUTO); |
Exigences de conversion
Si votre document SVG est protégé par un mot de passe, vous ne pouvez pas le convertir en XLTX sans le mot de passe. À l’aide de l’API, vous pouvez d’abord ouvrir le document protégé à l’aide d’un mot de passe valide et le convertir ensuite. Afin d’ouvrir le fichier crypté, vous pouvez initialiser une nouvelle instance du Document classe et transmettez le nom de fichier et le mot de passe comme arguments.
// supports PDF, CGM, EPUB, TeX, PCL, PS, SVG, XPS, MD, MHTML, XML, and XSLFO file format | |
// open PDF document | |
Document doc = new Document("input.pdf", "Your@Password"); | |
// save PDF as XLSX format | |
document.save("XlsxOutput.xlsx", SaveFormat.Xlsx); | |
// load the XLSX file in an instance of Workbook | |
Workbook book = new Workbook("XlsxOutput.xlsx"); | |
// supports CSV, XLSB, XLSM, XLT, XLTX, XLTM, XLAM, TSV, TXT, ODS, DIF, MD, SXC, and FODS file format | |
// save XLSX as CSV | |
book.save("output.csv", SaveFormat.AUTO); |
Convertir SVG protégé en XLTX via Java
Lors de la conversion du fichier SVG en XLTX, vous pouvez également ajouter un filigrane au format de votre fichier XLTX de sortie. Pour ajouter un filigrane, créez un nouveau classeur pour ouvrir le fichier XLSX converti. Sélectionnez Feuille de calcul via son index, créez une forme et utilisez sa fonction addTextEffect, définissez les couleurs, la transparence, etc. Après cela, vous pouvez enregistrer votre document XLSX au format XLTX avec filigrane.
// supports PDF, CGM, EPUB, TeX, PCL, PS, SVG, XPS, MD, MHTML, XML, and XSLFO file format | |
// load PDF with an instance of Document | |
Document document = new Document("template.pdf"); | |
// save document in XLSX format | |
document.save("XlsxOutput.xlsx", SaveFormat.Xlsx); | |
// load the XLSX file in an instance of Workbook | |
Workbook book = new Workbook("XlsxOutput.xlsx"); | |
// get the first default sheet | |
Worksheet sheet = book.getWorksheets().get(0); | |
// add Watermark | |
Shape wordart = sheet.getShapes().addTextEffect(MsoPresetTextEffect.TEXT_EFFECT_1, "CONFIDENTIAL", | |
"Arial Black", 50, false, true, 18, 8, 1, 1, 130, 800); | |
// get the fill format of the word art | |
FillFormat wordArtFormat = wordart.getFill(); | |
// set the color | |
wordArtFormat.setOneColorGradient(Color.getRed(), 0.2, GradientStyleType.HORIZONTAL, 2); | |
// set the transparency | |
wordArtFormat.setTransparency(0.9); | |
// make the line invisible | |
LineFormat lineFormat = wordart.getLine(); | |
lineFormat.setWeight(0.0); | |
// supports CSV, XLSB, XLSM, XLT, XLTX, XLTM, XLAM, TSV, TXT, ODS, DIF, MD, SXC, and FODS file format | |
// save XLSX as CSV | |
book.save("output.csv", SaveFormat.AUTO); |