Menu
  • HOME
  • TAGS

How to check in workbook sheet exist or not using JXL in selenium webdriver?

java,excel,selenium,selenium-webdriver,jxl

I have not get the answer of my question here but yeah now I got the solution and its work fine for me, please check the below code hope it will help you also: public class MainClass { private static final String BROWSER_PATH = "D:\\softs\\FF installed\\FF18\\firefox.exe"; private static final String...

Code executes successfully but the data is added in excel only at final iteration

java,excel,testng,jxl

Since everytime you are getting the sheet from book1 object, all the changes made are skipped except the last change. reference: WritableSheet firstSheet = book1.getSheet(0); What you could do is, change the return type of writeDataInCell() to WritableWorkBook and change the logic of calling area like this: public WritableWorkbook writeDataInCell(int...

Read Excel file and skip empty rows but not empty columns

java,excel,jxl

Try this: for (int i = 0; i < sheet.getRows(); i++) { boolean rowEmpty = true; String currentRow = ""; for (int j = 0; j < sheet.getColumns(); j++) { Cell cell = sheet.getCell(j, i); String con=cell.getContents(); if(con !=null && con.length()!=0){ rowEmpty = false; } currentRow += con + "|";...

Can't access cells properly using jxl in Java

java,excel,jxl

The first parameter is column not row. I think you may have mixed the two up. See Javadocs. Try: Cell cell = sheet.getCell(0, i); In any event, this is the line that is giving the error I am quite sure....

Trying to ouput exceptions to a file - how can I pass objects into catch block?

java,exception-handling,try-catch,jxl

Define it like this: public static void main(String[] args) { WritableWorkbook exceptionWB = null; try{ exceptionWB = Workbook.createWorkbook(new File("filename.xls"); WritableSheet excepSheet=exceptionWB.createSheet("Exceptions",0); int exceptionRow=1; for(int i=0; i<numberOfRecords;i++) { processRow(argument1, argument2, excepSheet, exceptionRow); } catch (Exception e) { //You should now have access to the exceptionWB Label exception1=new Label(0, exceptionRow, e.getMessage()); exceptionWB.write();...

Using JExcelApi to write BigInteger to xls with $ and , formatting

java,excel,xls,jxl,jexcelapi

Edit: You can convert a BigDecimal to double with the method .doubleValue(). Changed example to meet your needs. Try to create a custom NumberFormat like this: NumberFormat dollarCurrency = new NumberFormat(NumberFormat.CURRENCY_DOLLAR + " ###,###,###.00", NumberFormat.COMPLEX_FORMAT); WritableCellFormat dollarFormat = new WritableCellFormat(dollarCurrency); n = new Number(column, row, myBigDecimal.doubleValue(), dollarFormat); s.addCell(n); You can...

Incorrect image added on excel file with jxl library

java,image,inputstream,jxl

You actually have 2 problems. First, InputStream.available() gives an estimate of the number of bytes that can be read in the call to read(), not the full size of the stream. Second, read(byte[]) isn't guaranteed to read the number of bytes returned by available(). Rather, it returns the number of...

How to merge cell using POI in Java

java,apache-poi,jxl

You can use the CellReference to parse the required String, here is a example: String[] cellStrings = "A2:A8".split(":"); CellReference start = new CellReference(cellStrings[0]); CellReference end = new CellReference(cellStrings[1]); CellRangeAddress address = new CellRangeAddress(start.getRow(), end.getRow(), start.getCol(), end.getCol()); System.out.println(address); This should output: org.apache.poi.ss.util.CellRangeAddress [A2:A8] Then you can use addMergedRegion from your HSSFSheet...

Getting same color with different RGB value in Java

java,swing,jxl

You need a way to compare colors in Java. You could find relevant information here: how could i compare colors in java? Anyway: You need to compare for equality, not identity so: color == Color.BLACK must translate to Color.BLACK.equals(color) Since you need to compare approximately, you need a way to...

Label not being recognized even though jxl import and API are there

java,excel,jxl

In your imports you import two different Labels. One from java.awt and one from jxl.write. You get the error that the constructor is not defined so your code is most likely using the wrong Label wich does not have a constructor like that. And you also get the error that...

Output values from selenium webdriver to excel sheet

selenium,webdriver,jxl

You are creating a new Excel file effectively overwriting the previous one by creating the sheet inside the for loop. Try modifying the for loop part of your code as below File fExcel = new File("C:\\Users\\Master\\Desktop\\new.xls"); WritableWorkbook writableBook = Workbook.createWorkbook(fExcel); writableBook.createSheet("Data", 0); WritableSheet writableSheet = writableBook.getSheet(0); for(int i = 0;...

Updated excel file still returns old values

java,excel,jxl

I don't know the jxl library very well, and I couldn't get your example running (what import should I use for Number?), but: The Excel file formats not only stores formulas, but also the calculated results in the file. So when you change the values A and B, you somehow...