I can't save xlsx file getting No more data to read from socket error

OK let's get back to the problem. Now I've got Aspose.Cells 7.2.0 for java and still same problem. Java code is:

public static void Sav(String p_file_path) throws Exception
{
try {
CellsHelper.setFontDir("/tmp/Fonts");
Workbook workbook = new Workbook(p_file_path);
workbook.save(p_file_path+"saved.xlsx");


} catch(Exception e){
PrintStream out = null;
try {
out = new PrintStream(new FileOutputStream("/tmp/tmp1/error.txt"));
out.print(getStackTrace(e)); }
finally {
if (out != null) out.close();
}
}
}

Then I run it from Oracle wrapped in a procedure and getting "No more data to read from socket" error message, getting disconnected in Oracle environment and error.txt is not created

test1.xlsx in attach

all write access rights has been given to the Fonts folder on the server and test1.xlsx for a user "Oracle" who runs procedures.

can anyone help please?

Hi,

Thanks for your posting and using Aspose.Cells for Java.

The issue seems to be unrelated with Aspose.Cells for Java. From the error you stated, it looks like there is some network problem.

Please provide us a full stack trace to look into this issue further.

Hi,

Thanks for sharing the file and details.

We tested, it works fine on our Windows Environment. We are doing the test it on Oracle Environment as you pointed out, it will done soon. We think the error is not due to our component because we have never used the socket in our component at all. It is most likely due to you are using file/resources with oracle's procedure etc.

Anyways, to analyze the issue thoroughly and precisely, I have logged a ticket with an id: CELLSJAVA-40177. We will get back to you soon.

Thank you.

Hi,

We have tested your given template file by common application with windows env but cannot find any issue. Also we have tested it in Jsp and oc4j server and did not find any issue too. We think the issue should have nothing to do with our component. You should check whether you can get the data of the template file firstly when runing your code. Such as, you can use common Java IO APIs to get the data of template file, and then construct a ByteArrayInputStream from it and use the ByteArrayInputStream to load Workbook. For saving workbook, please save the workbook to ByteArrayOutputStream firstly and then save the data in ByteArrayOutputStream to file.

hi

I can put the data to sheets and even calculateFormula and get new data back. There is only the problem with saving...

How can I use BiteArrayOutputStream to work with the file? could you please give me a link to documentation or something?

thanks

Hi,

To use ByteArrayOutputStream for your situation, please see following code example:

C#


ByteArrayOutputStream baos = new ByteArrayOutputStream();

wb.save(baos, SaveFormat.XLSX);

byte[] data = baos.toByteArray();

FileOutputStream fos = new FileOutputStream(p_file_path+“saved.xlsx”);

fos.write(data);

fos.close();

still the same error…

Hi,

Please give us more details about the exception stack trace. For the code:

ByteArrayOutputStream baos = new ByteArrayOutputStream();
wb.save(baos, SaveFormat.XLSX);
byte[] data = baos.toByteArray();
FileOutputStream fos = new FileOutputStream(p_file_path+"saved.xlsx");

where the exception was thrown? At the line of “wb.save…” or “new FileOutputStream(…”?

Thank you.

the message is thrown here:

CellsHelper.setFontDir("/tmp/Fonts");


and there is nothing in stack error file. In fact, it doesn't create error stack file because it can't even reach Catch section

Hi,

It is strange that CellsHelper.setFontDir() caused such kind of error. In fact CellsHelper.setFontDir() does not use any IO operation. The specified font dirs only be accessed when user begin to use render or measure features.

Anyway, please remove the code of CellsHelper.setFontDir() and try your application again to test whether your code can work.

mshakeel.faiz:
Anyway, please remove the code of CellsHelper.setFontDir() and try your application again to test whether your code can work.

In this case there is a stack output:

java.lang.IllegalArgumentException: Cannot find required font defination[Family:Calibri, Style:0]. Please specify font path.
at com.aspose.cells.a.d.co.b(Unknown Source)
at com.aspose.cells.a.d.V.a(Unknown Source)
at com.aspose.cells.pj.a(Unknown Source)
at com.aspose.cells.rd.a(Unknown Source)
at com.aspose.cells.rd.a(Unknown Source)
at com.aspose.cells.Worksheet.autoFitRow(Unknown Source)
at com.aspose.cells.lY.a(Unknown Source)
at com.aspose.cells.gr.a(Unknown Source)
at com.aspose.cells.gr.C(Unknown Source)
at com.aspose.cells.gr.a(Unknown Source)
at com.aspose.cells.gq.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:297)

Hi,

Would you please test the code CellsHelper.setFontDir() itself? That is, please remove all other api invocations, in your application there is only one line code:


CellsHelper.setFontDir(…);


If you can get the socket error again, please try to access the specified font dir by java common IO APIs. Such as:

for(File ff = new File("/tmp/Fonts").listFiles())
{
byte[] data = new byte((int)ff.length());
FileInputStream fis = new FileInputStream(ff);
fis.read(data);
fis.close();
}

mshakeel.faiz:
Hi,

Would you please test the code CellsHelper.setFontDir() itself? That is, please remove all other api invocations, in your application there is only one line code:

CellsHelper.setFontDir(...);



no erros after that, passed silently...

Hi,

Then it seems it is not the code of CellsHelper.setFontDir() that caused the issue. How about accessing the files @ your specified path? Did you test the code we gave in previous post for accessing files by Java’s common IO APIs?

Thank you.

Amjad Sahi:

Hi,

Then it seems it is not the code of CellsHelper.setFontDir() that caused the issue. How about accessing the files @ your specified path? Did you test the code we gave in previous post for accessing files by Java’s common IO APIs?

Thank you.

I’ve just discovered that it crushed after adding workbook constructor:

CellsHelper.setFontDir("/tmp/tmp2/Fonts");
Workbook workbook = new Workbook(p_file_path);

All IO operations go well without Workbook class.

So that’s what we have:

working:

//CellsHelper.setFontDir("/tmp/tmp2/Fonts");
Workbook workbook = new Workbook(p_file_path);

working:

CellsHelper.setFontDir("/tmp/tmp2/Fonts");
//Workbook workbook = new Workbook(p_file_path);

not working:

CellsHelper.setFontDir("/tmp/tmp2/Fonts");
Workbook workbook = new Workbook(p_file_path);

Hi,


Thanks for your feedback.

We have logged it to add your comments with your issue. We will look into it further.

Thank you.

Hi,

We need you to test the code which we provided with reply at this post. Please test whether you can access those font files firstly by that code.

mshakeel.faiz:
Hi,

We need you to test the code which we provided with reply at this post. Please test whether you can access those font files firstly by that code.

I've tested it and it has no errors, acces is OK

Hi,

Thanks for your feedback.

We have logged your comments in our database and we will look into it and get back to you asap.

The comment has been logged against the issue id: CELLSJAVA-40177