Free Support Forum - aspose.com

ImportResultSet doesn't return all lines

Hi all,

I use a SQL request for importing my data. When I open my file I don’t have the first line of my SQL result. My result started at the second line.
Thanks for your answer.

Hi,


I am afraid, I am unable to replicate this issue on my end. I used the example given in Technical Article on Importing Data to Worksheet with Aspose.Cells JAVA v2.5.4.6 [attached]. Can you please test your requirement with this latest JAR and let us know of your results.

Thank you

Hi babar,

I downloaded the latest JAR but it didn’t work. In all files, the first result doesn’t appear.

Please help.

Hi,

Thanks for looking into it and your feedback. Can you please try it with the current latest JAR? If still it does not work then I will reopen your issue and post your comment.

Thanks for your cooperation.

Please download: Aspose.Cells for Java v2.5.4.9

Hi,

Thanks for your answer.
I change my JAR to the current latest but it’s not ok.
May be, it is because I’m using Rowmapper. If you have a better way to extract data from SQL request, please help.
But I can’t use the sample way described in the Importing data Demo.

Thanks

Hi,

I think maybe the issue exists in your implementation of the RowMapper. Did you check the elements in the list returned by the query method? Was there only one item? If there are more than one items, then you must have inserted records into the same place repeatedly and so the first rows be replaced. I think you can try to change your implementation of RowMapper like following and test whether you can get the correct result:
new RowMapper()
{
private rowIndex = 4;
public Object mapRow(ResultSet resultSet, int row) throws SQLException
{
int count = cell.importResultSet(resultSet, rowIndex, 0, false);
rowIndex += count;
return count;
}
}

Hi mshakeel.faiz,

I try your source but it’s not ok.

I don’t have the first line of Sql result.

Thanks

Hi,

We will see if we could help you any further. I have logged this issue in our database. We will update you asap.

This issue has been logged as CELLSJAVA-28776.

Hi,

Ok I m waiting for your answer.
Where can I see this issue CELLSJAVA-28776?


thanks

Hi,

You can’t see it because it is an internal issue id only accessible to Aspose Staff Members. I have written here to keep a reference to this thread.

Thanks for this information.

I just have a deployment on production tomorrow at 04:00 pm, so I am ready to test all you will suggest.

Thanks

Hi,

As far as I guess, your issue is totally related with database (drivers and libraries), it is unrelated with Aspose.Cells for Java.

I think, you should search over the internet why you are not able to create correct result set and what is the procedure of creating result set using your database.

I am afraid you will have to wait till tomorrow before Aspose.Cells for Java developers could give some feedback on your issue or solution and we could update you.

I will log a comment and notify the team to make sure, you do get some feedback tomorrow.

Thanks a lot for your help.

Yes I’m looking for on internet too.

Hi,

I think you need to check your ResultSet first. Please iterate every record in the ResultSet without using Cells.importResultSet() method. Test code can be following:

new RowMapper()

{

private rowIndex = 4;

public Object mapRow(ResultSet resultSet, int row) throws SQLException

{

ResultSetMetaData meta = resultSet.getMetaData();

int columnNum = meta.getColumnCount();

int count = 0;

while(resultSet.next())

{

count++;

System.out.println("Row index " + rowIndex);

for(int i=1; i<=columnNum; i++)

{

System.out.println(resultSet.getObject(i));

}

rowIndex++;

}

return count;

}

}

Please check whether the output includes all records you need to import. If it is true, please print out the “count” variable returned by cell.importResultSet() method in your original code to see whether it is correct.


Thank you.

Hi Amjad Sahi,

This code doesn’t work in my case.
I have the same result i.e without the first SQL result.

Thanks

Hi,

ImportResultSet can only be used with resultSet ?
When I use an other function of JDBC by Spring, I can’t.

Regards

Hi,


Now that you cannot get your desired first record from your resultSet, I am afraid the issue is not related to Aspose.Cells. I think you need to check your own code, such as, your SQL query, and the records in your database to see whether there is such a record (that exists) and whether your SQL query can fetch it from database fine.


Thanks for your understanding!

Hi,

My request is ok because I put some logs (System.out.println) and I checked it, I returned all record by using Oracle. It’s the same result when I used executeQuery (query). I think it a new Rowmapper which is wrong.

I found an other way to do that by inserting one test line in my database and doing an Order by, so that my first record (test) is not taken.

Thanks for all your solution