Code1 To Read XML Using JXL Api
Code1 To Read XML Using JXL Api
jxl.write.Label;
jxl.write.Number;
jxl.write.WritableSheet;
jxl.write.WritableWorkbook;
jxl.write.WriteException;
i2++;
}
//*** records from check xml**//
//**adding records from ID5**//
//System.out.println("printing id5");
ArrayList<String> arrId5 = new ArrayList<String>(50000);//id5 is col nam
e
Cell[] cellColumnid5 = checkSheet.getColumn(13);//cell col array
int cellCountid5 = cellColumnid5.length;
cellCountid5--;
//System.out.println("cells in col: " + cellCountid5);
int cellCount3 = cellCountid5;
int j = 1;
while(cellCountid5 != 0)
{
Cell cell5 = checkSheet.getCell(13,j);//to get the promo id values in ce
ll
String str5 = cell5.getContents();
// System.out.println(str5);
arrId5.add(str5);
cellCountid5--;
j++;
}
//**adding records from QTY8**//
// System.out.println("printing qty8");
ArrayList<String> arrQty = new ArrayList<String>(50000);//id5 is col nam
e
Cell[] cellColumnQty = checkSheet.getColumn(28);//cell col array
int cellCountQty = cellColumnQty.length;
cellCountQty--;
//System.out.println("cells in col: " + cellCountQty);
int cellCount7 = cellCountQty;
int j1 = 1;
while(cellCountQty != 0)
{
// System.out.println("m here");
Cell cell7 = checkSheet.getCell(28,j1);//to get the promo id values in c
ell
String str7 = cell7.getContents();
// System.out.println(str7);
arrQty.add(str7);
cellCountQty--;
j1++;
}
//**adding records from Discount Percent**//
//System.out.println("printing disc");
ArrayList<String> arrDisc = new ArrayList<String>(50000);//id5 is col na
me
Cell[] cellColumnDisc = checkSheet.getColumn(29);//cell col array
int cellCountDisc = cellColumnDisc.length;
cellCountDisc--;
//System.out.println("cells in col: " + cellCountDisc);
//to compare the first sheet's records with second sheet. one by one
int x = cellCount3;
int y = 0;
//ArrayList<String> matchId5 = new ArrayList<String>(20000);
ArrayList<String> resultPid = new ArrayList<String>(20000);
int r1 = 0;
String[] arrstr1 = new String[20000];
String[] arrstr2 = new String[20000];
String[] arrstr3 = new String[20000];
String[] arrstr4 = new String[20000];
String[] arrstr5 = new String[20000];
String[] arrstr6 = new String[20000];
String[] arrstr7 = new String[20000];
//to match the records of pid
do
{
cellCount2--;
//
cellCount5--;
//
cellCount6--;
//System.out.println("cellcount2 " + cellCount2);
cellCount3 = x;
do
{
cellCount3--;
//
cellCount7--;
//
cellCount8--;
System.out.println("cellcount3 " + cellCount3);
// && arrTh.get(cellCount2).equals(arrQty.get(cellCount3)) && arrOff.
get(cellCount2).equals(arrDisc.get(cellCount3))
if(arrPid.get(cellCount2).equals(arrId5.get(cellCount3))&& arrTh.get(cel
lCount2).equals(arrQty.get(cellCount3)) && arrOff.get(cellCount2).equals(arrDisc
.get(cellCount3)))
{
//if(arrTh.get(cellCount2).equals(arrQty.get(cellCount3)))
System.out.println("2 if");
{
//!arrDisc.get(cellCount3).isEmpty() &&
//if(arrOff.get(cellCount2).contains(arrDisc.get(cellCount3)))
{
Cell cell9 = checkSheet.getCell(27,cellCount3);//to get the promo id val
ues in cell
String str9 = cell9.getContents();
arrstr1[cellCount2] = str9;
Cell cell12 = dataSheet.getCell(8,cellCount2);//to get the promo id valu
es in cell
String str12 = cell12.getContents();
arrstr2[cellCount2] = str12;
Cell cell13 = dataSheet.getCell(5,cellCount2);//to get the promo id valu
es in cell
String str13 = cell13.getContents();
arrstr3[cellCount2] = str13;
System.out.println("arrstr3");
Cell cell14 = dataSheet.getCell(6,cellCount2);//to get the promo id valu
es in cell
String str14 = cell14.getContents();
arrstr3[cellCount2] = str14;
Cell cell15 = dataSheet.getCell(13,cellCount2);//to get the promo id val
ues in cell
String str15 = cell15.getContents();
arrstr4[cellCount2] = str15;
Cell cell16 = dataSheet.getCell(28,cellCount2);//to get the promo id val
ues in cell
String str16 = cell16.getContents();
arrstr5[cellCount2] = str16;
System.out.println("arrstr6");
Cell cell17 = dataSheet.getCell(29,cellCount2);//to get the promo id val
ues in cell
String str17 = cell17.getContents();
arrstr6[cellCount2] = str17;
//
//
//
//
//
//
//
//
//resultPid.add(str9);
String str7 = arrPid.get(cellCount2);
//System.out.println("str9 "+resultPid.get(r1));
//r1++;
System.out.println("value y" +y);
}
}
}
//System.out.println("out1");
} while(cellCount3 !=0);
System.out.println("out2");
} while(cellCount2 !=0);
System.out.println("out3");
int i10 = 1;
for(String Str11 : resultPid)
{
System.out.println("resultpid "+Str11);
System.out.println("Count "+i10);
i10++;
}
dataWorkbook.close();
checkWorkbook.close();
arrPid.clear();
arrId5.clear();
//adding values in csv file
//BufferedReader addedBuffer = new BufferedReader(new FileReader(add
edVendorFile.getAbsolutePath()));
try{
File outputFile = new File("result.csv");
BufferedWriter newFileBuffer = new BufferedWriter(new FileWriter(out
putFile));
if(outputFile.exists())
{
outputFile.delete();
outputFile.createNewFile();
}
else{
outputFile.createNewFile();
}
}
catch(IOException e)
{
e.printStackTrace();
}
//
//
//
//
//
//
//
//
//
//
//
//
//
writer.append(',');
writer.append(arrstr1[count]);
writer.append('\n');
}
//
//
//
//
//
//
//