Author Topic: Stylesheet in script generated document does not work  (Read 8091 times)

michielper

  • EA User
  • **
  • Posts: 176
  • Karma: +2/-1
    • View Profile
Stylesheet in script generated document does not work
« on: August 03, 2021, 06:38:45 pm »
I am generating reports with VBScript.
It is unclear to me how to use and set a stylesheet in order to have uniform fonts in the generated report. The function docGenerator.SetStyleSheetDocument does not seem to work.  I have also tried docGenerator.NewDocument("MyStyleSheet"), this has some effect but still the fonts in the generated document do not correspond with those in the stylesheet document. So what is the trick?
Any help is appreciated!

max

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: Stylesheet in script generated document does not work
« Reply #1 on: November 04, 2021, 09:29:08 pm »
Hi, I am facing the same problem. Could you find a solution?

PeteC

  • EA User
  • **
  • Posts: 91
  • Karma: +1/-0
    • View Profile
Re: Stylesheet in script generated document does not work
« Reply #2 on: March 16, 2022, 12:06:26 am »
Did either of you find a resolution? I'm using JScript and finding the same. If I manually update the stylesheet of the generated document afterwards then the script has applied the correct styles to the paragraphs (as those that I want bullets on then get bullets) but I should not need to do that.

PeteC

  • EA User
  • **
  • Posts: 91
  • Karma: +1/-0
    • View Profile
Re: Stylesheet in script generated document does not work
« Reply #3 on: March 17, 2022, 06:50:41 pm »
For anyone else finding this, I have now managed to overcome the issue, based on https://sparxsystems.com/forums/smf/index.php/topic,38810.0.html#msg240839.
When creating the document, you need to load a document template, e.g.: reporting.NewDocument("Blank"). The guidance says that the template can be blank (I'd assumed no template quoted between the quotes, but it might also mean an empty template!).
Within the template (I called it Blank), you need to load the Stylesheet that you will be using when adding text. Then the styles specified will be used. For belt and braces, I also have reporting.SetStyleSheetDocument("MyStyleSheet") to ensure that the right style sheet is used.
My suspicion is that this is not how Sparx intended it to work (otherwise I would expect the above to be in the documentation), but this provides a workaround.

michielper

  • EA User
  • **
  • Posts: 176
  • Karma: +2/-1
    • View Profile
Re: Stylesheet in script generated document does not work
« Reply #4 on: March 30, 2022, 01:06:38 am »
For anyone else finding this, I have now managed to overcome the issue, based on https://sparxsystems.com/forums/smf/index.php/topic,38810.0.html#msg240839.
When creating the document, you need to load a document template, e.g.: reporting.NewDocument("Blank"). The guidance says that the template can be blank (I'd assumed no template quoted between the quotes, but it might also mean an empty template!).
Within the template (I called it Blank), you need to load the Stylesheet that you will be using when adding text. Then the styles specified will be used. For belt and braces, I also have reporting.SetStyleSheetDocument("MyStyleSheet") to ensure that the right style sheet is used.
My suspicion is that this is not how Sparx intended it to work (otherwise I would expect the above to be in the documentation), but this provides a workaround.

Yes, my impression is that SetStyleSheetDocument("MyStyleSheet") should NOT be used because it messes up what is more or less ok using NewDocument("MyStyleSheet").

I encounter many problems regarding this EA-MSOffice interface. Paragraph numbers not formatted etc....