Results 1 to 4 of 4
- 09-21-2011, 12:25 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 52
- Rep Power
- 0
- 09-21-2011, 12:32 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: How to find empty string from a cell.
What do you mean by "highlighted"?
Are these specific cells?
If not, how do you determine which cells to check?
What excel package are you using?
JExcel, POI, something else?
- 09-21-2011, 12:45 PM #3
Member
- Join Date
- Mar 2011
- Posts
- 52
- Rep Power
- 0
Re: How to find empty string from a cell.
Thanks for reply,
I am using Aspose.java.cells API.
Java Code:Workbook workbook = new Workbook(); workbook.open(filename); Worksheet worksheet = workbook.getWorksheets().getSheet(sheetno); Cells cells=worksheet.getCells(); int num=cells.getMaxDataRow(); for (int n1=0;n1<=num;n1++) { Cell cell1=cells.getCell(n1,Colno); if(cell1.getValue()==null ||cell1.getValue().toString().length()==0) {Cell cell=cells.getCell(n1,Colno); Style style = cells.getCell( n1,Colno).getStyle(); style.setColor(Color.TEAL); cell.setStyle(style); } }
- 09-21-2011, 12:54 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: How to find empty string from a cell.
Unless Aspose works differently to other excel tools then it's possible this:
could return null, as Excel does not necessarily store a cell for empty cells. So worth bearing in mind.Java Code:Cell cell1=cells.getCell(n1,Colno);
After handling that, you could try trim()ing your toString() and then doing isEmpty() (rather than length() == 0)? It's a bit neater. That should cover space-only cells as well as empty ones.
Similar Threads
-
find first empty cell?
By truant420 in forum New To JavaReplies: 5Last Post: 03-15-2011, 01:13 PM -
getting rid of empty space at the end of a string
By BoomPony in forum New To JavaReplies: 3Last Post: 02-14-2011, 09:40 PM -
Test for all empty Strings in LinkedHashMap<String,ArrayList<String>
By albertkao in forum New To JavaReplies: 1Last Post: 11-04-2010, 06:53 PM -
How to find out if part of an array is empty
By counterfox in forum New To JavaReplies: 2Last Post: 10-13-2010, 06:09 PM -
JXL Empty cell problem
By ironicending in forum New To JavaReplies: 1Last Post: 01-26-2009, 03:32 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks