aspose-cells / aspose.cells-for-java Goto Github PK
View Code? Open in Web Editor NEWAspose.Cells for Java examples, plugins and showcases
Home Page: https://products.aspose.com/cells/java
License: MIT License
Aspose.Cells for Java examples, plugins and showcases
Home Page: https://products.aspose.com/cells/java
License: MIT License
When excel is converted to PDF, the default paper size is A4. How can I realize the custom size (such as 15cm*5cm)?
excel设置纸张大小21cm*9.7cm 生成pdf纸张是按A4大小的,如果设置了pdfSaveOptions.setOnePagePerSheet(true),纸张会按打印打印预览的大小,这个如何保存生成的pdf纸张和原excel一致
While Converting the excel file to Image I get the error com.aspose.cells.CellsException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed. Below is my Code
val workBook = Workbook(fileOptions.filePath)
val imgOptions = ImageOrPrintOptions()
imgOptions.imageType = ImageType.PNG
imgOptions.allColumnsInOnePagePerSheet = true
imgOptions.outputBlankPageWhenNothingToPrint = false
val sheet: Worksheet =
workBook.worksheets.get(workBook.worksheets.activeSheetIndex)
val sr = SheetRender(sheet, imgOptions)
for (j in 0 until sr.pageCount) {
// Generate an image for the worksheet
val imageFilePath = getPngFileName(fileOptions.filePath!!, j)
sr.toImage(j, imageFilePath)
mOutputFilePaths.add(imageFilePath)
Below is the excel file attached
源文件
bugFile.xls
Converting the attached file on a French computer produces incorrect PDF:
java -jar <my fat jar>
) all data rows are displayed in the PDF as ###### -Duser.language=fr_FR
option the dates are displayed, but in English way (month/day/year) - what I want is to display them French style: day/month/year - as they are displayed by Microsoft Excel or Libre Office.My Java code is basically this one:
Workbook workbook = new Workbook("marian3.xlsx");
int sheetCount = workbook.getWorksheets().getCount();
for (int s = 0; s < sheetCount; s++) {
Worksheet sheet = workbook.getWorksheets().get(s);
PageSetup pageSetup = sheet.getPageSetup();
pageSetup.setLeftMargin(MARGIN_CM); // private static final double MARGIN_CM = 0.4;
pageSetup.setRightMargin(MARGIN_CM);
pageSetup.setTopMargin(MARGIN_CM);
pageSetup.setBottomMargin(MARGIN_CM);
pageSetup.clearHeaderFooter();
}
PdfSaveOptions options = new PdfSaveOptions();
options.setOnePagePerSheet(true);
options.setCompliance(PdfCompliance.PDF_A_1_B); // NONE, PDF_A_1_A, PDF_A_1_B
options.setCustomPropertiesExport(PdfCustomPropertiesExport.STANDARD);
workbook.save("out.pdf", options);
Did I miss any option/parameter/... ?
I ran several examples of Excel-TIFF conversion and all outputs were corrupted.
OS: Mac Catalina 10.15.3
JDK: OpenJDK 11.0.1
Hi,
I have gone through with the sample code and I need to integrate this in my android app.In aspose portal you have mentioned it as library for Android via Java but it doesn't seem support the Android.
Can you please let me know how we can use the library in android app.
Thanks,
hi
I used the aspose cell in form of maven and it works
but now I want to merge the project with another java project using gradle (instead of maven)
but after adding the jar files downloaded from your site (from this page: https://downloads.aspose.com/cells/java), I face with this error:
error: package com.aspose does not exist
import com.aspose.cells.*
in the code I have written there is no error, but when I want to run the project (same code as the file which have worked in maven before) this error appears !
please help me!
many thanks in advance.
Trying to print a Xlsx to pdf and removing all protection from excel file, the output pdf file doesn´t include the excel data
workbook = new Workbook(rutaExcel);
vbaProject = workbook.getVbaProject();
vbaProject.protect(false, "");
WorksheetCollection worksheets = workbook.getWorksheets();
Worksheet worksheet = worksheets.get(1);
System.out.println("Esta protegido --> "+ worksheet.getProtection());
Protection protection = worksheet.getProtection();
// Restricting users to delete columns of the worksheet
protection.setAllowDeletingColumn(false);
// Restricting users to delete row of the worksheet
protection.setAllowDeletingRow(false);
// Restricting users to edit contents of the worksheet
protection.setAllowEditingContent(false);
// Restricting users to edit objects of the worksheet
protection.setAllowEditingObject(false);
// Restricting users to edit scenarios of the worksheet
protection.setAllowEditingScenario(false);
// Restricting users to filter
protection.setAllowFiltering(false);
// Allowing users to format cells of the worksheet
protection.setAllowFormattingCell(true);
// Allowing users to format rows of the worksheet
protection.setAllowFormattingRow(true);
// Allowing users to insert columns in the worksheet
protection.setAllowInsertingColumn(true);
// Allowing users to insert hyperlinks in the worksheet
protection.setAllowInsertingHyperlink(true);
// Allowing users to insert rows in the worksheet
protection.setAllowInsertingRow(true);
// Allowing users to select locked cells of the worksheet
protection.setAllowSelectingLockedCell(true);
// Allowing users to select unlocked cells of the worksheet
protection.setAllowSelectingUnlockedCell(true);
// Allowing users to sort
protection.setAllowSorting(true);
// Allowing users to use pivot tables in the worksheet
protection.setAllowUsingPivotTable(true);
// Saving the modified Excel file Excel XP format
worksheet.unprotect();
workbook.save(valorRuta, FileFormatType.XLSX);
workbook.save(valorRutaPDF, SaveFormat.PDF);
workbook.save(valorRutaPDF1, pdfSave);
workbook1 = new Workbook(valorRuta);
workbook1.save(rutaPDF, SaveFormat.PDF);
增加的sheet内容是:Evaluation Only. Created with Aspose.Cells for Java.Copyright 2003 - 2018 Aspose Pty Ltd.
Hi,
I have a Excel file which contains a hidden sheet.
For each sheet in the excel file. If I check like below:
Worksheet ws = (Worksheet) worksheetObj;
if (ws.isVisible() == false) {
logger.info("Hidden sheet found {} ", ws.getName());
}
I never i get to the logger statement because even for the hidden sheet isVisible is always 0.
Can somebody help how to know If the sheet is really hidden or not.
com.aspose.cells.CellsException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed
this problem occurred when I changed the server,The two servers have the same fonts,the original server is ok
/**
* excel 转为pdf 输出。
*
* @param sourceFilePath excel文件
* @param desFilePathd pad 输出文件目录
*/
public static void excel2pdf(String sourceFilePath, String desFilePathd) {
if (!getLicense()) { // 验证License 若不验证则转化出的pdf文档会有水印产生
return;
}
try {
Workbook wb = new Workbook(sourceFilePath);// 原始excel路径
// Worksheet worksheet = wb.getWorksheets().get(0);
// worksheet.getPageSetup().setPaperSize(PaperSizeType.PAPER_A_4_SMALL);
// System.out.println(worksheet.getPageSetup().getPaperSize());
FileOutputStream fileOS = new FileOutputStream(desFilePathd);
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setAllColumnsInOnePagePerSheet(true);
pdfSaveOptions.setOnePagePerSheet(false);
int[] autoDrawSheets = {3};
//当excel中对应的sheet页宽度太大时,在PDF中会拆断并分页。此处等比缩放。
autoDraw(wb,autoDrawSheets);
int[] showSheets = {0};
//隐藏workbook中不需要的sheet页。
printSheetPage(wb, showSheets);
wb.save(fileOS, pdfSaveOptions);
fileOS.flush();
fileOS.close();
log.info(desFilePathd + "生成完毕");
} catch (Exception e) {
e.printStackTrace();
}
}
I am converting an XLSX to PDF, essentially using the same code as in issue #48.
Using Worksheet#autoFitColumns()
when converting the following file
example.xlsx
produces an ugly result :
example-w_autoFit.pdf
(just look at the width of the columns Cecilia, Patty, Robert and Frank).
Without autoFitColumns
the result is OK :
example-normal.pdf
The code is essentially the same as in the #48 issue (#48).
I have used Aspose library 20.10 on an Ubuntu 18.04 system.
What can I do to improve the result when using autoFitColumns
?
把Excel转html后,我会把该静态页面直接浏览器打开,但没有title,如何在转换时添加<title>fileName</title>?
Java实现Excel对指定区域指定Sheet页截图,截图后图片中的文字和数字失真,该怎么处理勒
ImageOrPrintOptions imageOrPrintOptions = new ImageOrPrintOptions();
SheetRender sheetRender = new SheetRender(worksheet, imageOrPrintOptions);
sheetRender.toImage(0, “picPath“);
有什么方法,在excel转图片的时候,含有公式的表格数据也可以成功转到图片中?
如标题,Microsoft Excel在打印预览时,有缩放参数【无缩放】、【将工作表调整为一页】、【将所有列调整为一页】、【将所有行调整为一页】,那使用Aspose.Cell时,如何设置这些参数
Cell A1 = cells.get("A1");
A1.setValue("2021-01-02 23:59:59");
Cell B1 = cells.get("B1");
B1.setValue("2021-01-02 00:00:00");
String formula = "=DAYS(A1,B1)";
Cell C1 = cells.get("C1");
C1.setFormula(formula);
wb.calculateFormula(true);
System.out.println(C1.getValue());
计算结果为:1
而实际结果应该为:0
Hi!
I am trying to convert an Excel file (test.xlsx from the attached zip) to PDF.
test.zip
The Excel contains only a cell, written with the Angelina font downloaded from https://www.1001freefonts.com/angelina.font.
When saving the workbook, I use PdfSaveOptions#setCompliance(PdfCompliance.PDF_A_1_B)
and I am on a Linux computer (Ubuntu 20.04).
$ pdffonts no_font.pdf
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
FAAABA+Tibetan_Machine_Uni CID TrueType Identity-H yes yes yes 10 0
pdffonts
produces the same result!$ fc-match
DejaVuSans.ttf: "DejaVu Sans" "Book"
So:
Aspose.Cells
to pick a font ?样例:在excel单元格中写入&=entity.age,可以获取到所有entity.age的值,怎样才能只获取entity.name为张三的对象的age属性
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.