We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Read whole/entire column at once from CSV

Hi,

I was wandering if there is any mechanism that allows to read the hole column from e.g. CSV file at once. I know I can iterate through with use of loops, but I would like to avoid that, since I will have a lot of data (rows) . Is there any feature that allows me to grab the hole column (data in it), and e.g. gives me back the array list of cells or something like that ?

I know that I can do somehting like that:
Column column = new Workbook().get(0).getCells().getColumn(0); // BTW it is deprecated
But I can not get any data from this object. I guess I can use it for changing the style.

Any help would be appreciated,
cheers

I am using JAVA and AsposeCells 7.3.1

@pawelforums,

Thanks for your query.

I think you may try to use Cells.exportArray() method if it suits your needs, see the sample code segment below for your reference:
e.g
Sample code:

........
int numCol =1;
Object dataTable [][] = worksheet.getCells().exportArray(0,0, numRows,numCol);
//Printing array
for(int r = 0; r < numRow; r++)
{
    for(int c = 0; c < numCol; c++)
    {
         System.out.print(dataTable[r][c]);
    }
    System.out.println();
} 
.........

Hope, this helps a bit.

Than you for the solution, but I think that for CSV file it will not work that fine…When I use code above it actually reads hole row with all ’ ; '. So e.g. in my file I have:
123;123;123;123
235;235;235;235
567;567;567;567

And in final result I would like to have [123,235,567] - hole first column. Your code works fine for excel reading, but not for CVS. Do you have how I could improve it?

IT WORKS!

I had you set the load options:

    TxtLoadOptions opts = new TxtLoadOptions();
    opts.setSeparator(';');

thanks you for your help! :slight_smile:

@pawelforums,

Good to know that your issue is sorted out now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.