Page 1 of 1

Problem applying Font to Cells

PostPosted: Mon Jun 24, 2013 9:19 pm
by mrOlicas
Hello Jason and all,

do I have to take sth. special in consideration when applying fonts like this:

Code: Select all
    // Font for data cell row has font index = 3
    CTFont fontDataRow = new CTFont();

    CTFontSize fdrSize = new CTFontSize();
    fdrSize.setVal( planFormat.getFontSizeGroups() );
    JAXBElement<CTFontSize> element19 = smlObjectFactory.createCTFontSz( fdrSize );
    fontDataRow.getNameOrCharsetOrFamily().add( element19 );

    CTColor fdrColor = new CTColor();
    fdrColor.setTheme( 1L );
    JAXBElement<CTColor> element20 = smlObjectFactory.createCTFontColor( fdrColor );
    fontDataRow.getNameOrCharsetOrFamily().add( element20 );

    CTFontName fdrFontName = new CTFontName();
    fdrFontName.setVal( "Times New Roman" );
    JAXBElement<CTFontName> element21 = smlObjectFactory.createCTFontName( fdrFontName );
    fontDataRow.getNameOrCharsetOrFamily().add( element21 );


and

Code: Select all
    // Date Cell XF
    CTXf xf3 = new CTXf();
    xf3.setNumFmtId( 0L );
    xf3.setFontId( 3L );
    xf3.setFillId( 0L );
    xf3.setBorderId( 0L );
    xf3.setXfId( 0L );
    xf3.setApplyFont( Boolean.TRUE );
    xfs.getXf().add( xf3 );
//..


So I am using the right indexes I think; the font size and bold is being applied, for instance. But I cannot get the font itself to change to Arial, Cambria or anything else, it always stays as "Calibri". Do I need a special order for setting the properties?

Does somebody know what is missing?

Thanks in andvance

mrOlicas

Re: Problem applying Font to Cells

PostPosted: Mon Jun 24, 2013 9:33 pm
by mrOlicas
Hello,

i figured it out: I was using this font scheme, minor:

Code: Select all
    CTFontScheme fschema1 = new CTFontScheme();
    fschema1.setVal( STFontScheme.MINOR );
    JAXBElement<CTFontScheme> element9 = smlObjectFactory.createCTFontScheme( fschema1 );
    fontGroups.getNameOrCharsetOrFamily().add( element9 );


which i think blocked me somehow. I deleted it and now everything works fine (but I still dont know exactly why).

If someone has a link to the OpenXML specification, please post it here, i am sure some others will be happy too ;-)

cheers,

mrOlicas

Re: Problem applying Font to Cells

PostPosted: Mon Jun 24, 2013 10:42 pm
by jason

Re: Problem applying Font to Cells

PostPosted: Thu Aug 08, 2013 8:52 pm
by juse
Hi,
can you please post the code example to apply bold to a single cell or a single row?

Thanks!

Get cell values for range.

PostPosted: Wed Sep 25, 2013 4:03 pm
by arohi
So I am using the right indexes I think; the font size and bold is being applied, for instance. But I cannot get the font itself to change to Arial, Cambria or anything else, it always stays as "Calibri". Do I need a special order for setting the properties?