Book a Demo

Author Topic: Script export to Excel: format notes  (Read 3447 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Script export to Excel: format notes
« on: October 23, 2020, 09:03:15 pm »
Hi,

I have a custom EA script that exports class details in Excel. I'm looking for a way to preserve the formatting (bold, italics, colours...) in the Excel cell.

I tried the various combinations of GetFieldFromFormat + GetFormatFromField  methods on a sample text:

cellValue without any update
'text in <b>bold</b>
text in <i>italics</i> <u>underlined </u>text
<font color="#ff0000">red text, </font><font color="#0000ff">blue</font>, <font color="#ffff00">yellow</font>'

Repository.GetFieldFromFormat("HTML", cellValue)
'text in <b>bold</b> text in <i>italics</i> <u>underlined </u>text <font color="#ff0000">red text, </font><font color="#0000ff">blue</font>, <font color="#ffff00">yellow</font>'

Repository.GetFieldFromFormat("TXT", cellValue)
'text in &lt;b&gt;bold&lt;/b&gt;
text in &lt;i&gt;italics&lt;/i&gt; &lt;u&gt;underlined &lt;/u&gt;text
&lt;font color="#ff0000"&gt;red text, &lt;/font&gt;&lt;font color="#0000ff"&gt;blue&lt;/font&gt;, &lt;font color="#ffff00"&gt;yellow&lt;/font&gt;'

Repository.GetFormatFromField("HTML ", cellValue)
'text in <b>bold</b> text in <i>italics</i> <u>underlined </u>text <font color="#ff0000">red text, </font><font color="#0000ff">blue</font>, <font color="#ffff00">yellow</font>'

Repository.GetFormatFromField("TXT ", cellValue)
'text in bold
text in italics underlined text
red text, blue, yellow'

I currently use the latest option to remove all formatting. In Geert's VBImporter, the update is done using VBA Excel functions. I wonder if there's a way to transform via an EA script the cellValue so each specific text has the appropriate format applied i.e. to get the following in the Excel cell:
text in bold
text in italics underlined text
red text, blue, yellow


« Last Edit: October 23, 2020, 09:06:47 pm by Guillaume »
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Script export to Excel: format notes
« Reply #1 on: October 23, 2020, 09:11:15 pm »
Guillaume,

You should be able to translate this VBA code to internal EA script code (using the Excel API)

Geert