java - Generating xml graphs using POI -


i using poi create report in xls format. enhanced show graphs data in report. per limitation of poi, cannot create graphs in excel. so, using template , rewriting data in everytime , graph gets refreshed.

cell cell = row.getcell(columnsarray[j1]); cell.setcellvalue(integer.valueof(count)); 

bad practice, have hardcode position of cells in array.

int columnsarray[] = {     1,2,3,4,5,6,7,8,9,10 }; 

anyone using better approach or other alternative of poi achieve this?

thanks in advance, gv

till apache poi limitation saying "you can not create charts. can create chart in excel, modify chart data values using hssf , write new spreadsheet out. possible because poi attempts keep existing records intact far possible".

however in same case, have created chart manually on excel sheet using named ranges , using java, updating named ranges per requirement. since chart based on named ranges updated.

you can update existing reference of named ranges , set per requirement. suppose reference contains mysheet!$a$1:$b$8and want change mysheet!$b$5:$c$12

for cell, "b5", @ runtime,

cell.getreference();  

will give cell reference (like in example... return "b5")

char startcellcolref = cell.getreference().tostring().charat(0);  

will give column reference (will give "b" if current cell b5). now

int startcellrowref = cell.getreference().tostring().charat(1); 

will give row index (will give "5" if current cell b5).

by same way can start , end cell references (say b5 , c12).

now comes how can update existing references. update value newly created reference string

name reference = wb.getname("namereferenceinexcelsheet"); referencestring = sheetname+"!$"+startcellcolref+"$"+startcellrowref+":$"+endcellcolref+"$"+endcellrowref; reference.setreferstoformula(referencestring); 

by way need create name ranges manually , graph/chart want manually based on named ranges, , need update named ranges... since chart/graph based on that, updated automatically.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -