Calling - JAVA Expets ..... Chalanachithram.com | Topics | Search
Hide Clipart | Log Out | Register | Edit Profile

Last 30 mins | 1 | 2 | 4 hours     Last 1 | 7 Days

Chalanachithram.com DB » New TF Industry Related » Archive through November 27, 2013 » Calling - JAVA Expets ..... « Previous Next »

Author Message
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26962
Registered: 10-2007
Posted From: 204.235.114.64

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, November 26, 2013 - 05:11 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Myselfme:

if(!cellContent.equals(""))
sb.append("<"+colname+">"+ cellContent + "<"+colname+">\n");


Man ur awesome code is working like GEM.

Cheat code kakunda other code time unnappudu update cheyu n keep in touch ya..till this project gets over.

Once again Thank You Myselfme.
Top of pagePrevious messageNext messageBottom of page Link to this message

Myselfme
Junior Artist
Username: Myselfme

Post Number: 127
Registered: 04-2011
Posted From: 166.147.104.154

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, November 26, 2013 - 04:58 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

colName with capital N, post automatically converting to lower case
Top of pagePrevious messageNext messageBottom of page Link to this message

Myselfme
Junior Artist
Username: Myselfme

Post Number: 126
Registered: 04-2011
Posted From: 166.147.104.157

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, November 26, 2013 - 04:54 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

See lines in red

Sorry I cannot use my office computer, posting from my phone, there are typos

if(cellContent.equals(""))
sb.append("<"+colname+">"+cellContent+"</"+colname+">\n");
Top of pagePrevious messageNext messageBottom of page Link to this message

Myselfme
Junior Artist
Username: Myselfme

Post Number: 125
Registered: 04-2011
Posted From: 166.147.104.159

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, November 26, 2013 - 04:47 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

Posted on Monday, November 25, 2013 - 05:00 pm:
Myselfme:
My final code:

public static void main(String [] args) throws Exception {
String xml="";
StringBuilder sb = new StringBuilder();
try {

FileInputStream file = new FileInputStream(new File("C:\temp\Simple.xlsx"));

//Get the workbook instance for XLS file
XSSFWorkbook wb = new XSSFWorkbook(file);


Sheet s = wb.getSheetAt(0);// workbook.getSheet(sheetName);
sb.append("<?xml>\n");
sb.append("<data>\n");

int count = 0;
int rowCount = 0;

// First row contains column names

Row row = s.getRow(0);
int noofrows = s.getPhysicalNumberOfRows();

int numColumns = row.getPhysicalNumberOfCells();

if (row == null)
throw new Exception("Cannot get row 0 from sheet " + s);

String colNames[] = new String[numColumns];
Cell[] cells = new Cell[numColumns];

// Get column names from first row
for (int i = 0; i < numColumns; ++i) {
cells[i] = row.getCell(i);

String cname = cells[i].getStringCellValue();
if (cells[i].getCellType() != Cell.CELL_TYPE_BLANK) {
String colName = cname.trim();
// Make sure column name contains only allowed characters.

colNames[i] = colName;
/* validate columsn**/

}
}
// Loop over rows in this sheet

Row tempRow;
for (int i = 1; i < noofrows; i++) {

tempRow = s.getRow(i);

Cell cell = tempRow.getCell(0);

//if(cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK)
//continue;

int excelRow = i + 1;
// bw.write(" <row>\n");
/* write data to xml format required here */

// Loop over columns in this row
for (int j = 0; j < numColumns; ++j) {
// In case this row has more
// columns than the fist row.
// Then ignore this extra column.
if (j >= numColumns)
continue;

cell = tempRow.getCell(j);

String colName = colNames[j];
String cellContent = "";
if (cell != null) {
int celltype = cell.getCellType();
if (j == 0 && celltype == Cell.CELL_TYPE_BLANK) {
rowCount++;
}
if (celltype == Cell.CELL_TYPE_STRING) {
if (cell.getStringCellValue() != null)
//cellContent = xmlEncode(cell.getStringCellValue());
cellContent = cell.getStringCellValue();
else
cellContent = "";
} else if (celltype == Cell.CELL_TYPE_NUMERIC) {
cellContent = Double.toString(cell
.getNumericCellValue());
} else {
cellContent = "";
}

} else {
if (j == 0)
rowCount++;
}
// bw.write(" <">" + cellContent + "</" +
// colName + ">\n");

If(cellContent.equals("")
sb.append("<"+colname+">"+ cellContent + "</"+colname+">");

}

// bw.write(" </row>\n");
//TEMP sb.append("</xxxxx>\n");
}

sb.append("</data>\n");



}catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();

}
System.out.println(sb);
}
}}
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26961
Registered: 10-2007
Posted From: 204.235.114.64

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, November 26, 2013 - 03:20 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Myselfme:

sb.append("<"+colname+">"+cell.getStringCellValue()+"</"+col name+">\n");

Try above line


Master Post Number: 26955 lo naa final code chudandi and colname is something defined down below but this cheat code top lo use cheyamantunnaru..so colname top lo define ekkada ela cheyali?thx
Top of pagePrevious messageNext messageBottom of page Link to this message

Myselfme
Junior Artist
Username: Myselfme

Post Number: 124
Registered: 04-2011
Posted From: 166.147.104.172

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, November 26, 2013 - 10:10 am:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

colName? Or colname?

Case sensitive
Top of pagePrevious messageNext messageBottom of page Link to this message

Myselfme
Junior Artist
Username: Myselfme

Post Number: 123
Registered: 04-2011
Posted From: 166.147.104.172

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, November 26, 2013 - 10:07 am:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

sb.append("<"+colname+">"+cell.getStringCellValue()+"</"+col name+">\n");

Try above line
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26960
Registered: 10-2007
Posted From: 204.235.114.64

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, November 26, 2013 - 09:54 am:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Myselfme:

if(!cellContent.equals(""))
sb.append("<"+colname+">"+ cellContent + "<"+colname+">\n");

Prasthuthaniki cheating....remaining I will try tomorrow




Code ni below ga change chesa but ????? place lo emi ravali lo artham kadam ledu

if(!cell.getStringCellValue().equals(""))
sb.append("<???>"+ cell.getStringCellValue() + "</???>\n");
Top of pagePrevious messageNext messageBottom of page Link to this message

Myselfme
Junior Artist
Username: Myselfme

Post Number: 122
Registered: 04-2011
Posted From: 98.206.237.162

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, November 26, 2013 - 12:34 am:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

//if (cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK)
//continue;

*******

if(!cellContent.equals(""))
sb.append("<"+colname+">"+ cellContent + "<"+colname+">\n");
*******


Prasthuthaniki cheating....remaining I will try tomorrow
Top of pagePrevious messageNext messageBottom of page Link to this message

Botsa_fan
Junior Artist
Username: Botsa_fan

Post Number: 187
Registered: 07-2013
Posted From: 24.165.127.206

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, November 25, 2013 - 09:22 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

http://viralpatel.net/blogs/java-read-write-excel-file-apach e-poi/
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26956
Registered: 10-2007
Posted From: 75.181.140.190

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, November 25, 2013 - 08:19 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Myselfme:

I looked at the fonts, not the merged cell, I will work and send you new code,
But how font forma should be written depends on XML parser?


lets forget about font formation right now...ur awesome bro, thanks a lot
Top of pagePrevious messageNext messageBottom of page Link to this message

Myselfme
Junior Artist
Username: Myselfme

Post Number: 121
Registered: 04-2011
Posted From: 166.147.104.145

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, November 25, 2013 - 08:13 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

I looked at the fonts, not the merged cell, I will work and send you new code,
But how font forma should be written depends on XML parser?
Top of pagePrevious messageNext messageBottom of page Link to this message

Thakita_thakita
Comedian
Username: Thakita_thakita

Post Number: 1239
Registered: 07-2011
Posted From: 148.106.4.6

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, November 25, 2013 - 05:03 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

this is going to be very complicated one. As you have merged cell and some non merged cells in there. Code provided in this thread won't work. You need to use merged content feature in POI
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26955
Registered: 10-2007
Posted From: 204.235.114.64

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, November 25, 2013 - 05:00 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Myselfme:


My final code:

public static void main(String [] args) throws Exception {
String xml="";
StringBuilder sb = new StringBuilder();
try {

FileInputStream file = new FileInputStream(new File("C:\temp\Simple.xlsx"));

//Get the workbook instance for XLS file
XSSFWorkbook wb = new XSSFWorkbook(file);


Sheet s = wb.getSheetAt(0);// workbook.getSheet(sheetName);
sb.append("<?xml>\n");
sb.append("<data>\n");

int count = 0;
int rowCount = 0;

// First row contains column names

Row row = s.getRow(0);
int noofrows = s.getPhysicalNumberOfRows();

int numColumns = row.getPhysicalNumberOfCells();

if (row == null)
throw new Exception("Cannot get row 0 from sheet " + s);

String colNames[] = new String[numColumns];
Cell[] cells = new Cell[numColumns];

// Get column names from first row
for (int i = 0; i < numColumns; ++i) {
cells[i] = row.getCell(i);

String cname = cells[i].getStringCellValue();
if (cells[i].getCellType() != Cell.CELL_TYPE_BLANK) {
String colName = cname.trim();
// Make sure column name contains only allowed characters.

colNames[i] = colName;
/* validate columsn**/

}
}
// Loop over rows in this sheet

Row tempRow;
for (int i = 1; i < noofrows; i++) {

tempRow = s.getRow(i);

Cell cell = tempRow.getCell(0);
if (cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK)
continue;
int excelRow = i + 1;
// bw.write(" <row>\n");
/* write data to xml format required here */

// Loop over columns in this row
for (int j = 0; j < numColumns; ++j) {
// In case this row has more
// columns than the fist row.
// Then ignore this extra column.
if (j >= numColumns)
continue;

cell = tempRow.getCell(j);

String colName = colNames[j];
String cellContent = "";
if (cell != null) {
int celltype = cell.getCellType();
if (j == 0 && celltype == Cell.CELL_TYPE_BLANK) {
rowCount++;
}
if (celltype == Cell.CELL_TYPE_STRING) {
if (cell.getStringCellValue() != null)
//cellContent = xmlEncode(cell.getStringCellValue());
cellContent = cell.getStringCellValue();
else
cellContent = "";
} else if (celltype == Cell.CELL_TYPE_NUMERIC) {
cellContent = Double.toString(cell
.getNumericCellValue());
} else {
cellContent = "";
}

} else {
if (j == 0)
rowCount++;
}
// bw.write(" <">" + cellContent + "</" +
// colName + ">\n");
sb.append("<"+colname>" + cellContent + "</">\n");
}

// bw.write(" </row>\n");
//TEMP sb.append("</xxxxx>\n");
}

sb.append("</data>\n");



}catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();

}
System.out.println(sb);
}

}

Above code is generating below xml

<?xml>
<data>
<integrationcode>D217</integrationcode>
<description>Desc1</description>
<highlighttext>Highlight1</highlighttext>
<sequence>1.0</sequence>
<promotion>Promotion1</promotion>

<integrationcode>V217</integrationcode>
<description>Desc2</description>
<highlighttext>Highlight1</highlighttext>
<sequence>1.0</sequence>
<promotion>Promotion2</promotion>

<integrationcode>S217</integrationcode>
<description>Desc3</description>
<highlighttext>Highlight1</highlighttext>
<sequence>1.0</sequence>
<promotion>Promotion3</promotion>
</data>

HighlightText is not repeating, even though it has multiple data lines
Top of pagePrevious messageNext messageBottom of page Link to this message

Myselfme
Junior Artist
Username: Myselfme

Post Number: 120
Registered: 04-2011
Posted From: 166.147.104.143

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, November 25, 2013 - 02:25 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

bw.append continuation went to next line, just bring it to same line
Top of pagePrevious messageNext messageBottom of page Link to this message

Myselfme
Junior Artist
Username: Myselfme

Post Number: 119
Registered: 04-2011
Posted From: 166.147.104.147

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, November 25, 2013 - 02:21 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

int rowCount = 0;
String sheetName = "Sheet1"; // you can automatically get this

xmlEncode is for replacing any extra characters like &, <,> which will screw up XML parsers, you can override it later just comment it out
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26953
Registered: 10-2007
Posted From: 204.235.114.64

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, November 25, 2013 - 12:44 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

> rowCount var ledu
> xmlEncode function ledu
> bw.append formation looks odd to me and formatting error too.
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26952
Registered: 10-2007
Posted From: 204.235.114.64

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, November 25, 2013 - 12:40 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

public void convert(String input, String output) throws Exception {
Workbook wbs;
InputStream inp = new FileInputStream(input);
wbs = WorkbookFactory.create(inp);
/*
* if(isXlsx(input)) wbs = new XSSFWorkbook(inp); else { POIFSFileSystem
* fs = new POIFSFileSystem(inp); wbs = new HSSFWorkbook(fs); }
*/
StringBuffer warnings = new StringBuffer();
writeXml(wbs, output);
inp.close();
}
/**
* Parse a workbook and write out contents into an xml file.
*/
private void writeXml(Workbook workbook, String output) throws Exception {
if (workbook == null)
throw new Exception("Null workbook");

if (output == null)
throw new Exception("Null xml filename");

if (output.length() == 0)
throw new Exception("Zero length xml filename");

FileOutputStream out = new FileOutputStream(output);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out,
"UTF8"));

try {

Sheet s = workbook.getSheetAt(0);// workbook.getSheet(sheetName);

if (s == null)
throw new Exception("Cannot get sheet " + sheetName
+ " from this workbook");

bw.write("<?xml>\n");
bw.write("<data>\n");

int count = 0;

// First row contains column names

Row row = s.getRow(0);
int noofrows = s.getPhysicalNumberOfRows();

int numColumns = row.getPhysicalNumberOfCells();

if (row == null)
throw new Exception("Cannot get row 0 from sheet " + sheetName);

String colNames[] = new String[numColumns];
Cell[] cells = new Cell[numColumns];


// Get column names from first row
for (int i = 0; i < numColumns; ++i) {
cells[i] = row.getCell(i);
if (cells[i] == null) {
Log.warn("Column name " + i + " is null");
continue;
}
String cname = cells[i].getStringCellValue();
if (cells[i].getCellType() != Cell.CELL_TYPE_BLANK) {
String colName = cname.trim();
// Make sure column name contains only allowed characters.

colNames[i] = colName;
/* validate columsn**/

}
}


// Loop over rows in this sheet

Row tempRow;
for (int i = 1; i < noofrows; i++) {

tempRow = s.getRow(i);

Cell cell = tempRow.getCell(0);
if (cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK)
continue;
int excelRow = i + 1;
// bw.write(" <row>\n");
/* write data to xml format required here */

// Loop over columns in this row
for (int j = 0; j < numColumns; ++j) {
// In case this row has more
// columns than the fist row.
// Then ignore this extra column.
if (j >= numColumns)
continue;

cell = tempRow.getCell(j);

String colName = colNames[j];
String cellContent = "";
if (cell != null) {
int celltype = cell.getCellType();
if (j == 0 && celltype == Cell.CELL_TYPE_BLANK) {
rowCount++;
}
if (celltype == Cell.CELL_TYPE_STRING) {
if (cell.getStringCellValue() != null)
cellContent = xmlEncode(cell
.getStringCellValue());
else
cellContent = "";
} else if (celltype == Cell.CELL_TYPE_NUMERIC) {
cellContent = Double.toString(cell
.getNumericCellValue());
} else {
cellContent = "";
}

} else {
if (j == 0)
rowCount++;
}
// bw.write(" <">" + cellContent + "</" +
// colName + ">\n");
bw.append("<">" + cellContent + "</"
+ colName + ">\n");

}

// bw.write(" </row>\n");
bw.write("</xxxxx>\n");
}

bw.write("</data>\n");
bw.flush();

} catch (Exception e) {
throw new Exception("Cannot convert excel data to xml: "
+ e.getMessage());
} finally {
bw.close();
}


--------------------

Myselfme, Could you take a look at those RED lines?? Thx
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26951
Registered: 10-2007
Posted From: 75.181.140.190

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, November 24, 2013 - 09:47 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Myselfme:

If you have teamviewer installed on your laptop I will show you , give me your email


Thx annai, but I want try myself first ..tomorrow jdev or eclipse lo try chesta..doubts vaste post cjesta..appatiki problem unte desktop chare chesta. Once again Thx bro.
Top of pagePrevious messageNext messageBottom of page Link to this message

Myselfme
Junior Artist
Username: Myselfme

Post Number: 118
Registered: 04-2011
Posted From: 98.206.237.162

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, November 24, 2013 - 08:56 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

My functions will work , if you spend an hour on the code below, problem is I cannot provide some missing statements, copy these to eclipse, call these functions from from main function , add apache poi jars to path, remove any statements creating problem,


You should know statement by statement from beginning itself, otherwise , if you want change something, it's difficult ,

If you have teamviewer installed on your laptop I will show you , give me your email
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26950
Registered: 10-2007
Posted From: 75.181.140.190

Rating: N/A
Votes: 0 (Vote!)

Posted on Sunday, November 24, 2013 - 08:07 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

bump tp keep active..
Top of pagePrevious messageNext messageBottom of page Link to this message

One
Hero
Username: One

Post Number: 16388
Registered: 09-2008
Posted From: 192.210.137.161

Rating: N/A
Votes: 0 (Vote!)

Posted on Saturday, November 23, 2013 - 01:08 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

J$F, easy thing to do .. first try cheyi .. raka pothey post cheyi ekkada struck ayyavo .. motham evadoo chesthey neku ela vasthundi
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26949
Registered: 10-2007
Posted From: 75.181.140.190

Rating: N/A
Votes: 0 (Vote!)

Posted on Saturday, November 23, 2013 - 12:15 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Dma:

you want an application or one time deal?


nope on demand annattu..3rd party will call through webservice we have to pass all the excel info annatu
Top of pagePrevious messageNext messageBottom of page Link to this message

Dma
Hero
Username: Dma

Post Number: 10929
Registered: 11-2009
Posted From: 72.201.132.90

Rating: N/A
Votes: 0 (Vote!)

Posted on Saturday, November 23, 2013 - 03:48 am:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Just4fun:

itta kuda seyachha ..inkoncham li8 eyanadi master




you want an application or one time deal?

if it is one time, yes. open in excel and save as xml, manually.
Vote for Decoits... Bring back Pizzaa Rule...
Keep Decoits Away... Keep Congress Away...

sthothram sthothram sthothram

Jai Andhra!! Jai Jai Andhra!!!
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26947
Registered: 10-2007
Posted From: 75.181.140.190

Rating: N/A
Votes: 0 (Vote!)

Posted on Saturday, November 23, 2013 - 02:39 am:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Abhysg:

Open excel save as Xml

Khel khatam


itta kuda seyachha ..inkoncham li8 eyanadi master
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26946
Registered: 10-2007
Posted From: 75.181.140.190

Rating: N/A
Votes: 0 (Vote!)

Posted on Saturday, November 23, 2013 - 02:38 am:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Cyberabadsinnodu:

nenu chestunna mama


Awesome mama..

Emc2:

String builder use chesi XML create cheyyi ess,first data extract cheyyi, Mari spoon feeding ante ela


Master Java edo bommal chusi nerchukunnam..not an expert. Will try String builder
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26945
Registered: 10-2007
Posted From: 75.181.140.190

Rating: N/A
Votes: 0 (Vote!)

Posted on Saturday, November 23, 2013 - 02:36 am:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Cocanada:

You can do programming in excel using VBA


Cokesh, converting to xml in JAVA will make my task easy, as I have to expose those values as WEB Service
Top of pagePrevious messageNext messageBottom of page Link to this message

Abhysg
Hero
Username: Abhysg

Post Number: 12926
Registered: 08-2008
Posted From: 198.228.200.20

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 07:41 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

Open excel save as Xml

Khel khatam
no siggy
Top of pagePrevious messageNext messageBottom of page Link to this message

Emc2
Megastar
Username: Emc2

Post Number: 20534
Registered: 03-2008
Posted From: 71.246.229.243

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 04:54 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Just4fun:




String builder use chesi XML create cheyyi ess,first data extract cheyyi, Mari spoon feeding ante ela
Top of pagePrevious messageNext messageBottom of page Link to this message

Emc2
Megastar
Username: Emc2

Post Number: 20533
Registered: 03-2008
Posted From: 71.246.229.243

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 04:53 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Cocanada:




Oopukuntu half knowledge tho vachesav ,out amma
Top of pagePrevious messageNext messageBottom of page Link to this message

Cyberabadsinnodu
Side Hero
Username: Cyberabadsinnodu

Post Number: 9906
Registered: 02-2010
Posted From: 63.243.17.163

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 04:50 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Just4fun:

@Other JAVA experts, excel sheet ichha, xml format ichha..bore kodite kasta POC chesi code pass cheyandi babulu


nenu chestunna mama...let me see how it goes...:D
Chudappa Dber appa...nenu NRI ne kani...allu DB sudaru nenu chusta anthe teda..aina last post manadhi aithe daniki vache kick ee verappa..
Top of pagePrevious messageNext messageBottom of page Link to this message

Cocanada
Legend
Username: Cocanada

Post Number: 43958
Registered: 01-2008
Posted From: 168.244.164.254

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 04:23 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

excel is binary file.
can we read it as byte stream????
Top of pagePrevious messageNext messageBottom of page Link to this message

Cocanada
Legend
Username: Cocanada

Post Number: 43957
Registered: 01-2008
Posted From: 168.244.164.254

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 04:10 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

you need a VBA expert. Not Java expert

You can do programming in excel using VBA
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26944
Registered: 10-2007
Posted From: 204.235.114.64

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 04:06 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

@Other JAVA experts, excel sheet ichha, xml format ichha..bore kodite kasta POC chesi code pass cheyandi babulu
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26943
Registered: 10-2007
Posted From: 204.235.114.64

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 04:06 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

@Emc2, nuvvu cheppina links lo general ga ela cheyachho undi..but exact naa req format loki convert cheyalantE java skills kavali..manaki li8 ga telusu

@Myselfme, nee code edo exact ga naaku kavalsinattu unndi will do some POC , doubts unte aduguta
Top of pagePrevious messageNext messageBottom of page Link to this message

Myselfme
Junior Artist
Username: Myselfme

Post Number: 117
Registered: 04-2011
Posted From: 166.147.104.157

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 03:50 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

I have few conditions for excel, remove them
Top of pagePrevious messageNext messageBottom of page Link to this message

Myselfme
Junior Artist
Username: Myselfme

Post Number: 116
Registered: 04-2011
Posted From: 166.147.104.157

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 03:48 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

you can use below code


/* input : excel file
* output : xml file
*/

public void convert(String input, String output) throws Exception {
Workbook wbs;
InputStream inp = new FileInputStream(input);
wbs = WorkbookFactory.create(inp);
/*
* if(isXlsx(input)) wbs = new XSSFWorkbook(inp); else { POIFSFileSystem
* fs = new POIFSFileSystem(inp); wbs = new HSSFWorkbook(fs); }
*/
StringBuffer warnings = new StringBuffer();
writeXml(wbs, output);
inp.close();
}
/**
* Parse a workbook and write out contents into an xml file.
*/
private void writeXml(Workbook workbook, String output) throws Exception {
if (workbook == null)
throw new Exception("Null workbook");

if (output == null)
throw new Exception("Null xml filename");

if (output.length() == 0)
throw new Exception("Zero length xml filename");

FileOutputStream out = new FileOutputStream(output);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out,
"UTF8"));

try {

Sheet s = workbook.getSheetAt(0);// workbook.getSheet(sheetName);

if (s == null)
throw new Exception("Cannot get sheet " + sheetName
+ " from this workbook");

bw.write("<?xml>\n");
bw.write("<data>\n");

int count = 0;

// First row contains column names

Row row = s.getRow(0);
int noofrows = s.getPhysicalNumberOfRows();

int numColumns = row.getPhysicalNumberOfCells();

if (row == null)
throw new Exception("Cannot get row 0 from sheet " + sheetName);

String colNames[] = new String[numColumns];
Cell[] cells = new Cell[numColumns];


// Get column names from first row
for (int i = 0; i < numColumns; ++i) {
cells[i] = row.getCell(i);
if (cells[i] == null) {
Log.warn("Column name " + i + " is null");
continue;
}
String cname = cells[i].getStringCellValue();
if (cells[i].getCellType() != Cell.CELL_TYPE_BLANK) {
String colName = cname.trim();
// Make sure column name contains only allowed characters.

colNames[i] = colName;
/* validate columsn**/

}
}


// Loop over rows in this sheet

Row tempRow;
for (int i = 1; i < noofrows; i++) {

tempRow = s.getRow(i);

Cell cell = tempRow.getCell(0);
if (cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK)
continue;
int excelRow = i + 1;
// bw.write(" <row>\n");
/* write data to xml format required here */

// Loop over columns in this row
for (int j = 0; j < numColumns; ++j) {
// In case this row has more
// columns than the fist row.
// Then ignore this extra column.
if (j >= numColumns)
continue;

cell = tempRow.getCell(j);

String colName = colNames[j];
String cellContent = "";
if (cell != null) {
int celltype = cell.getCellType();
if (j == 0 && celltype == Cell.CELL_TYPE_BLANK) {
rowCount++;
}
if (celltype == Cell.CELL_TYPE_STRING) {
if (cell.getStringCellValue() != null)
cellContent = xmlEncode(cell
.getStringCellValue());
else
cellContent = "";
} else if (celltype == Cell.CELL_TYPE_NUMERIC) {
cellContent = Double.toString(cell
.getNumericCellValue());
} else {
cellContent = "";
}

} else {
if (j == 0)
rowCount++;
}
// bw.write(" <">" + cellContent + "</" +
// colName + ">\n");
bw.append("<">" + cellContent + "</"
+ colName + ">\n");
}

// bw.write(" </row>\n");
bw.write("</xxxxx>\n");
}

bw.write("</data>\n");
bw.flush();

} catch (Exception e) {
throw new Exception("Cannot convert excel data to xml: "
+ e.getMessage());
} finally {
bw.close();
}
Top of pagePrevious messageNext messageBottom of page Link to this message

Emc2
Megastar
Username: Emc2

Post Number: 20532
Registered: 03-2008
Posted From: 128.229.4.22

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 03:37 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

other option is xl ni xml loki impor chesi chudu,you will get an idea how it looks like

XL lo ee option undi chuu
Top of pagePrevious messageNext messageBottom of page Link to this message

Emc2
Megastar
Username: Emc2

Post Number: 20531
Registered: 03-2008
Posted From: 128.229.4.22

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 03:35 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Just4fun:




HSSFWorkbook use cheyyi, you will see the properties,

http://viralpatel.net/blogs/java-read-write-excel-file-apach e-poi/
Top of pagePrevious messageNext messageBottom of page Link to this message

Rudraksha
Side Hero
Username: Rudraksha

Post Number: 2039
Registered: 07-2012
Posted From: 70.181.57.58

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 03:34 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

http://www.onjava.com/pub/a/onjava/2003/04/16/poi_excel.html
Top of pagePrevious messageNext messageBottom of page Link to this message

Rudraksha
Side Hero
Username: Rudraksha

Post Number: 2038
Registered: 07-2012
Posted From: 70.181.57.58

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 03:27 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Just4fun:

any example or blog post ??


http://poi.apache.org/spreadsheet/how-to.html#sxssf
Top of pagePrevious messageNext messageBottom of page Link to this message

Rudraksha
Side Hero
Username: Rudraksha

Post Number: 2037
Registered: 07-2012
Posted From: 70.181.57.58

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 03:26 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Emc2:



ante ippudu xml lo kooda colored tags create cheyala
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26942
Registered: 10-2007
Posted From: 204.235.114.65

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 03:25 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Emc2:

simple POI use chesi read the xl cell properties and populate those as xml tag attribute,


any example or blog post ??

@Rudra, not in csv..its EXCEL
Top of pagePrevious messageNext messageBottom of page Link to this message

Rudraksha
Side Hero
Username: Rudraksha

Post Number: 2036
Registered: 07-2012
Posted From: 70.181.57.58

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 03:25 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Emc2:

CSV lo neeku bold italic properties ekkadanunchi vasthayi, think think


Top of pagePrevious messageNext messageBottom of page Link to this message

Emc2
Megastar
Username: Emc2

Post Number: 20530
Registered: 03-2008
Posted From: 128.229.4.22

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 03:24 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Rudraksha:

is it comma separated data




CSV lo neeku bold italic properties ekkadanunchi vasthayi, think think
Top of pagePrevious messageNext messageBottom of page Link to this message

Rudraksha
Side Hero
Username: Rudraksha

Post Number: 2035
Registered: 07-2012
Posted From: 70.181.57.58

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 03:22 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

is it comma separated data (CSV)??
Top of pagePrevious messageNext messageBottom of page Link to this message

Emc2
Megastar
Username: Emc2

Post Number: 20528
Registered: 03-2008
Posted From: 128.229.4.22

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 03:08 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

simple POI use chesi read the xl cell properties and populate those as xml tag attribute,

you can use those later use for rebuilding the xl,
Top of pagePrevious messageNext messageBottom of page Link to this message

Just4fun
Megastar
Username: Just4fun

Post Number: 26941
Registered: 10-2007
Posted From: 204.235.114.64

Rating: N/A
Votes: 0 (Vote!)

Posted on Friday, November 22, 2013 - 03:04 pm:   Insert Quote Edit PostDelete PostPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

I have a ExcelSheet (Simple.xlsx) looks like below
IntegrationCodeDescription HighlightText Squence Promotion
A217 Desc1 Highlight1 1 Promotion1
Highlight22
Highlight33
Highlight44
D217 Desc2 Highlight1 1 Promotion2
Highlight22
Highlight33
S217 Desc3 Highlight1 1 Promotion3
Highlight22


Need to convert above excel to xml* like below using Java, Apache POI, and Apache Tika

<getoffercontent>
<offer>
<integrationcode>A217</integrationcode>
<description>Desc1</description>
<highlights>
<highlighttext>Highlight1</highlighttext>
<sequence>1</sequence>
<highlighttext>Highlight2</highlighttext>
<sequence>2</sequence>
<highlighttext>Highlight3</highlighttext>
<sequence>3</sequence>
<highlighttext>Highlight4</highlighttext>
<sequence>4</sequence>
</highlights>
<promotion>Promotion1</promotion>
</offer>
<offer>
<integrationcode>D217</integrationcode>
<description>Desc2</description>
<highlights>
<highlighttext>Highlight1</highlighttext>
<sequence>1</sequence>
<highlighttext>Highlight2</highlighttext>
<sequence>2</sequence>
<highlighttext>Highlight3</highlighttext>
<sequence>3</sequence>
</highlights>
<promotion>Promotion2</promotion>
</offer>
<offer>
<integrationcode>S217</integrationcode>
<description>Desc3</description>
<highlights>
<highlighttext>Highlight1</highlighttext>
<sequence>1</sequence>
<highlighttext>Highlight2</highlighttext>
<sequence>2</sequence>
</highlights>
<promotion>Promotion3</promotion>
</offer>
</getoffercontent>


-----------------------------
* Have to read bold , italic, color as it is
** excel sheet can be download at
https://drive.google.com/file/d/0B6weOGC6OtYaa19ZY3Q3QjRoT2M /edit?usp=sharing

JAVA experts randi babu randi ..mee tadaka chupinchandi

Add Your Message Here
Post:
Bold text Italics Underline Create a hyperlink Insert a clipart image HASH(0x84c2448){Movie Clipart}
Show / hide regular icons selection options

Click on following links to open cliparts by Alphabetical Order

 A   B   C   D   E   F   G   H   I   J   K   L   M  

 N   O   P   Q   R   S   T   U   V   W   X   Y   Z  

Show / Hide Filmy icons selection options

Click on following links to open cliparts by Alphabetical Order

 A   B   C   D   E   F   G   H   I   J   K   L   M  

 N   O   P   Q   R   S   T   U   V   W   X   Y   Z  

Username: Posting Information:
This is a public posting area. Enter your username and password if you have an account. Otherwise, enter your full name as your username and leave the password blank. Your e-mail address is optional.
Password:
E-mail:
Options: Enable HTML code in message
Automatically activate URLs in message
Action: