0

How can I use WritableFont in ColdFusion ?

variables.labelObj=loader.create("jxl.write.Label");
variables.numberObj=loader.create("jxl.write.Number");
variables.formulaObj = loader.create("jxl.write.Formula");
variables.cellColor = loader.create("jxl.format.Colour");
variables.border = loader.create("jxl.format.Border");
variables.borderLineStyle = loader.create("jxl.format.BorderLineStyle");
variables.cellFormat = loader.create("jxl.write.WritableCellFormat"); 
variables.WritableFont = loader.create("jxl.write.WritableFont");
variables.CellXFRecord = loader.create("jxl.write.biff.CellXFRecord");

I'm using WritableCellFormat correctly.

test = variables.cellFormat.init();
test.setBorder(border.ALL,borderLineStyle.THIN,cellColor.BLACK);

But I'm not using WritableFont. Please give me simple code example how can I using WritableFont in coldfusion ?

I'm writing this code

newFont = variables.WritableFont.createFont("Arial"); test = variables.cellFormat.init(newFont);

but given error:

Unable to find a constructor for class jxl.write.WritableCellFormat that accepts parameters of type ( jxl.write.WritableFont$FontName )

Changed my code after @leigh advice and solve my issue

newFont = variables.WritableFont.init(WritableFont.ARIAL,16); test = variables.cellFormat.init(newFont);

Leigh
  • 28,765
  • 10
  • 55
  • 103
  • If the objective is to create formatted spreadsheets using ColdFusion, you could always use the the ColdFusion code that does that. You can google "ColdFusion Spreadsheet Functions" to do it. If you want to use a java api, you can create an java object in ColdFusion that gives you access to everything in that object. The CreateObject() function gets you started on that. – Dan Bracuk Jul 31 '15 at 11:52
  • Have you looked at the [API](http://jexcelapi.sourceforge.net/resources/javadocs/2_3/docs/jxl/write/WritableFont.html)? Just skimming it suggests you need to create a WritableFont object using the desired font name, size, etcetera. Then pass the font object into your cell format ie `variables.cellFormat.init(yourFont );`. – Leigh Aug 02 '15 at 16:36
  • thank you for answer.But my issue continue – Egemen Ates Aug 03 '15 at 10:28
  • If you look at the API, `createFont` returns a font *name*, not a font object. To create a new font object, you need to use the constructor - ie `init()` method - with the appropriate values ie font name, font size, etcetera. For example, try something like `WritableFont.init(WritableFont.ARIAL, 16)`. – Leigh Aug 03 '15 at 13:36
  • @Leigh Thank You Solve issue. – Egemen Ates Aug 04 '15 at 13:04

1 Answers1

0

Just to close out this thread...

If you look at the API, the WriteableFont.createFont() method returns a font name. Whereas WriteableCellFormat is expecting a font object.

To create a new font object, you need to use the constructor, ie init() method, with the appropriate values (font name, font size, etcetera). For example:

  yourFont = WritableFont.init( WritableFont.ARIAL, 16 );

Then pass that object into the WriteableCellFormat constructor:

  yourFormat = variables.cellFormat.init( yourFont );
Leigh
  • 28,765
  • 10
  • 55
  • 103