Excel Trucos

Page 285

310

Excel.Los mejorestrucos

HSSFCeIlStyfe cs2 = l^rb.createCeflStyfe( HSSFDataFormat df = $/b.createDataFormat( para ef formato dos objeEos fuente HSSFFont fl = wb.createFont( ); ftssltOnE T¿ = wD.CreaE.e¡Ont ( ) ;

); );

/ /

crea

/ /

1 a tamaño 10 y negrita esLablece Ia fuente ( (short) 10) ; f1. setFontHeightlnPoints f L . s e t B o l d v ¡ e i g h t ( H S S F F o n t . B O L D W E I G H T _ B O L)D;

//a<fal¡1a¡o

1

frrañt^

-

ts-ñ-ñ^

1 f v^

!' y

ó e ¡l r

¡u ¡vl lnvr!

rt vn Ji nv

( (short) 10) ; f2. setFontHeightlnPoints (short)HSSFFont.co],oR RED ) ; f2.setcolor( //nara datos |

|

y q L s

1 de celda-

e'l esfilo

rsar

fuenfe

1 v cstaLrlecer

el

formato

de

csl-. setFont (f1) ; c s l - . s e t D a t a F o r m a t s( d f . g e t F o r m a t ( " # , # # 0 . 0 " ) ) ; borde fino y el estilo 2 de celda. usar fuente 2, establecer //para formato de texto cs2. setBorderBottom (cs2.BoRDER_THIN); j-nFormat ( " text " ) )' cs2 . setDataFormat (HSSFDataFormat . getBuilt cs2 . setFont (f2 ) ; //

csfahlece

el

nomtrre

dc

hnia

cn

TTniggdg

wb.se!SheetName(0, "Hoja de prueba", H S S F W o T k b o o k . E N C O D I N GU T F L 6 ) ; //

crea una hoja con 10 filas (rownum = (short) for

(0-9) 0r ror^¡num < 10;

rownum++)

I I

/ / crea una fila r = ws.createRow(rownum)

;

//r.setRohrNum(( short ) rownum); (el += 2 se entenderá luego) // crea seis celdas(0-5) (short cellnum = (short) 0; cellnum < 6; cellnum += 2) for I

/ / crea una celda numérica (ceflnum) ; c = r.createceff / / rel-l-ena con números basándose en 1a posición * 10 + ceflnum c.setcellva1ue(rownum + (((double) rownum / 10) + ((double) cefl-num / r00))); / / crea una cefda de texto ( (short) (ceflnum c = r.createcell // if f t

cada dos filas ( (rownum Z 2)

(por eso fo == O)

+ 1) ) ;

de +=2)


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.