executing the procedure
public static void Sav(String p_file_path, String p_sheet, String p_cell_in, String p_cell_out, float p_val) throws Exception
{
Workbook workbook = new Workbook(p_file_path);
Cells cells = workbook.getWorksheets().get(p_sheet).getCells();
Cell cell_in = cells.get(p_cell_in);
cell_in.putValue(p_val);
workbook.save(p_file_path);
}
I'm getting this error:
java.lang.IllegalArgumentException: Cannot find required font defination[Family:Arial, Style:1]. Please specify font path.
at com.aspose.cells.a.c.cf.b(Unknown Source)
at com.aspose.cells.a.c.cf.a(Unknown Source)
at com.aspose.cells.t.a(Unknown Source)
at com.aspose.cells.pM.a(Unknown Source)
at com.aspose.cells.pM.a(Unknown Source)
at com.aspose.cells.pM.a(Unknown Source)
at com.aspose.cells.Worksheet.autoFitRow(Unknown Source)
at com.aspose.cells.kM.a(Unknown Source)
at com.aspose.cells.WorksheetCollection.r(Unknown Source)
at com.aspose.cells.WorksheetCollection.a(Unknown Source)
at com.aspose.cells.WorksheetCollection.b(Unknown Source)
at com.aspose.cells.WorksheetCollection.a(Unknown Source)
at com.aspose.cells.WorksheetCollection.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at xxCells.Sav(xxCells:17)
Any thoughts?
Java 1.4.2
Regards
Hi,
Please set the correct font path at the begin of your program, such as code like following:
CellsHelper.setFontDir("c:\\windows\\fonts"); //for common windows os
Thank you.
thanks for a quick reply. I put Fonts as you said and now it's giving me this:
java.lang.NullPointerException
at com.aspose.cells.b.a.b.g.(Unknown Source)
at com.aspose.cells.b.a.b.g.(Unknown Source)
at com.aspose.cells.pM.a(Unknown Source)
at com.aspose.cells.pM.a(Unknown Source)
at com.aspose.cells.pM.a(Unknown Source)
at com.aspose.cells.Worksheet.autoFitRow(Unknown Source)
at com.aspose.cells.kM.a(Unknown Source)
at com.aspose.cells.WorksheetCollection.r(Unknown Source)
at com.aspose.cells.WorksheetCollection.a(Unknown Source)
at com.aspose.cells.WorksheetCollection.b(Unknown Source)
at com.aspose.cells.WorksheetCollection.a(Unknown Source)
at com.aspose.cells.WorksheetCollection.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at xxCells.Sav1(xxCells:36)
Hi,
Thank you for your feedback. Which version of aspose.cells for Java are you using now? Would you please try the latest version V7.0.2.5? In recent fixes we have made some enhancements for doing with fonts, including enhancement for such kind of NullPointerException. If you still get this exception with the new fix, please give us more details about your OS, JDK and font settings so we can make further investigation.
Thank you.
ok I installed 7.0.2.5 it doesn't help but the stack changed:
java.lang.NullPointerException
at com.aspose.cells.b.a.b.g.(Unknown Source)
at com.aspose.cells.b.a.b.g.(Unknown Source)
at com.aspose.cells.vI.a(Unknown Source)
at com.aspose.cells.WorksheetCollection.aa(Unknown Source)
at com.aspose.cells.WorksheetCollection.(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)
at xxCells.Sav1(xxCells:24)
and another question: how can I get formula cell updated? I need to put some number to a cell (PutValue()) and then read some value from a different cell in the same sheet with a formula inside. At the moment it’s not updated and gives me just old saved value frmo a formula cell.
Hi,
I think, you should call workbook.calculateFormula() and then read the results. This method will calculate the values of all the formulas and you will be able to get the correct value.
mshakeel.faiz:
Hi,
I think, you should call workbook.calculateFormula() and then read the results. This method will calculate the values of all the formulas and you will be able to get the correct value.
it gives me
java.lang.NullPointerException
at com.aspose.cells.b.a.b.g.(Unknown Source)
at com.aspose.cells.b.a.b.g.(Unknown Source)
at com.aspose.cells.vI.a(Unknown Source)
at com.aspose.cells.WorksheetCollection.aa(Unknown Source)
at com.aspose.cells.WorksheetCollection.(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)
at xxCells.Sav1(xxCells:25)
join:
Hi,
Thank you for your feedback. Which version of aspose.cells for Java are you using now? Would you please try the latest version V7.0.2.5? In recent fixes we have made some enhancements for doing with fonts, including enhancement for such kind of NullPointerException. If you still get this exception with the new fix, please give us more details about your OS, JDK and font settings so we can make further investigation.
Thank you.
is this jar for java 1.4?
here are jars I loaded to make it work(probably it'll give you an idea):
jsr173_1.0_api.jar
dom4j-1.6.1.jar
stax2-api-3.1.1.jar
woodstox-msv-rng-datatype-20020414.jar
jaxb-libs-1.5.jar
woodstox-msv-core-2.0.0.jar
woodstox-msv-xsdlib-2.0.0.jar
woodstox-core-asl-4.0.10.jar
bcprov-jdk14-146.jar
xercesImpl.jar
aspose-cells-7.0.2.5.jar
Hi,
After analyzing the issue, from the stack trace you provided, we think any simple template file can reproduce this exception at your end. But we cannot re-produce it here on our end. We will soon provide you a new version of the product. Hopefully, it will sort out your issue.
Thank you.
I attached a file to the post above
Hi,
I am unable to reproduce the exception using the following code. I used the latest version:
Aspose.Cells for Java v7.0.2.6
Please see the output xls file.
Here is a list of jar files being used. These are specific to JDK 1.6.
- aspose-cells-7.0.2.6.jar
- bcprov-jdk16-146.jar
- dom4j-1.6.1.jar
- stax2-api-3.0.2.jar
- woodstox-core-asl-4.1.1.jar
Java
String path = “F:\Shak-Data-RW\Downloads\test.xls”;
Workbook workbook =
new Workbook(path);
workbook.save(path + “.
out.xls”);
Hi,
Such kind of issue are normally caused by the incorrect font path, so please make sure the font path you set was the correct one that contains the font files for all fonts used in your Excel file.
We have checked the possible code that may cause such kind of Exception and made some improvements for doing with Font. Please try the new version(V7.0.3):
http://www.aspose.com/community/files/72/java-components/aspose.cells-for-java/entry342254.aspx
to see whether the exception has been fixed. If not, we are afraid we have to provide some debug versions to trace this issue at your end.
I installed cells.7.0.3 and calculateFormula started to work, thanks!
But now I encountered another problem. If I put this code:
CellsHelper.setFontDir("/tmp/Aspose/fonts");
it's ending up with weird oracle message No more data to read from socket.
If I comment that string, CalculateFormula works fine, but Save operation causes Cannot find required font defination[Family:Arial, Style:1]
again.
Any thoughts? Maybe I should change that string leading to Fonts folder? what is usually supposed to be in that folder? I just copied Fonts from c/:windows to the linux server
Cheers
Hi,
Please check whether the specified path "/tmp/Aspose/fonts" exists and you have access rights for it. Also please call setFontDir() at the beginings of your application before using any other functionalities of cells component. And we think it will be better for you to isolate the issue by creating a console application to test your code without any server environment dependence. If you still get the issue, please give us more details about it, such as the exception stack trace.
Thank you.
join:
Hi,
Please check whether the specified path "/tmp/Aspose/fonts" exists and you have access rights for it. Also please call setFontDir() at the beginings of your application before using any other functionalities of cells component. And we think it will be better for you to isolate the issue by creating a console application to test your code without any server environment dependence. If you still get the issue, please give us more details about it, such as the exception stack trace.
Thank you.
I would think something wrong with the folder, but it didn't give me this error on Cells.7.0.2.5
So I think some changes in cells java classes causing it. Here is my simple class:
public static String Sav1(String p_file_path, String p_sheet, String p_cell_in, String p_cell_out, float p_val) throws Exception
{
try {
CellsHelper.setFontDir("/tmp/Fonts");
Workbook workbook = new Workbook(p_file_path);
Cells cells = workbook.getWorksheets().get(p_sheet).getCells();
cells.get(p_cell_in).putValue(p_val);
return cells.get(p_cell_out).getStringValue();
} catch(Exception e){
PrintStream out = null;
try {
out = new PrintStream(new FileOutputStream("/tmp/MOVE/error.txt"));
out.print(getStackTrace(e)); }
finally {
if (out != null) out.close(); return null;
}
}
}
can't get any stack cause it just stopping at CellsHelper.setFontDir("/tmp/Fonts/");
if I comment this string - everything is fine. BUT I need this string if I want to save a file, otherwise it gives me initial font error message. So the problem is somewhere in CellsHelper.setFontDir("/tmp/Fonts/"); and the folder is ok, I could read it in 7.0.2.5
And I also checked access rights to that folder, even chmoded it - drwxrwxrwx. So that's not an access issue.
Hi there
Just encountered another problem. Now it's really complicated workbook with many sheets and formulas. Trying to workbook.calculateFormula(); in Pricing sheet to put a new value to BW4 and get value from BX4 cell and getting this:
com.aspose.cells.CellsException: null
Error in calculating cell M6 in Worksheet Summary at com.aspose.cells.Workbook.calculateFormula(Unknown Source)
at com.aspose.cells.Workbook.calculateFormula(Unknown Source)
at xxCells.Sav1(xxCells:31)
If I comment workbook.calculateFormula(); then it just giving me old value of BX4
Hi,
For formula calculation issue, kindly attach your template file, so that we could check your issue soon.
Thank you.