I have a excel file in which 10 rows of data is written manually and later deleted 9 rows of data by selecting and pressing 'Delete(Keyboard button)'. While i read the file in apex its showing 10 rows of data in which 9 rows are getting as:

1st row data,

... so on

As a result, my code is throwing exceptions. Is there a way to restrict it?

1 Answer 1


You can easily do this. Remove all comma and check for size and if length == 0 then ignore the line.

for(String line: lines) {
       if (line.replaceAll(',','').trim().length() == 0) break;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .