Change the default font of the tables

Hi!!

If I’m not mistaken, the default font for the tables written with an Excel Writer node is Calibri-11. Using the Continental nodes I manage to change the font size, but I would like also to change the font from Calibri to Arial. Is there a way to change it?

Thank you very much in advance!! :slight_smile:

Best regards,
Carolina

Hi @CarolinaPR ,

Unfortunately I could not see any mechanisms within the existing XLS nodes for specifying the default font either. The XLS Font Formatter node appears to format everything except for the actual chosen font. I could not find any other nodes that would assist directly either.

So I came up with only one solution, unless somebody else has another suggestion. But it does require Python 3 to be available. Do you have Python 3 and the openpyxl package installed for use with your KNIME environment? If you do, you can try out an “Excel Font Changer” component I have put together using a Python Script node.

It doesn’t change the “default” font, but what it will do is set the font for the existing cells on a specified sheet within an XLSX that has already been written.

The intention (and it seems to work) is that it leaves all other attribute of each cell (size, colour, italic, bold) untouched, and just modifies the font name.

e.g. font set to “Algerian”:

font set to “Arial”
image

and just for giggles… font set to “Wingdings” :wink:
image

A demo workflow can be found here:


and the component is here:

It’s very much a proof of concept, but it does the job. It might be a little slow if you have very large spreadsheets as it has to set every cell individually. There doesn’t appear to be a way of setting it across an entire sheet in Openpyxl.

If you are able to use it, and you find it could do with some refinements, let me know and I’ll do what I can to assist.

3 Likes

Dear @takbb,

thank you very much for your answer! This is great! I will try that!

Have a great day! :slight_smile:

Best regards
Carolina

1 Like