for future inquiries from other users:
footer Writer options:
https://forum.openoffice.org/en/forum/viewtopic.php?t=104958
Header Calc options:
from com.sun.star.awt import FontWeight
def set_header_ctt(header_content):
doc = XSCRIPTCONTEXT.getDocument()
sheets = doc.Sheets
#more options: https://wiki.openoffice.org/wiki/Documentation/DevGuide/Text/Text_Fields
field_sn = doc.createInstance("com.sun.star.text.TextField.SheetName")
field_date = doc.createInstance("com.sun.star.text.TextField.DateTime")
field_date.IsDate = True
header_content.CenterText.String = ''
oCursor = header_content.CenterText.createTextCursor()
oCursor.CharHeight = 9 #change font size
# oCursor.CharFontName = 'verdana'
# oCursor.CharWeight = FontWeight.BOLD
# oCursor.CharHeight = 15
# oCursor.CharColor = 0x7f0000 # dark red
# oCursor.CharPosture = 'ITALIC'
""" print(oCursor.CharFontName)
print(oCursor.CharWeight)
print(oCursor.CharHeight)
print(oCursor.CharPosture) """
oCursor.gotoEnd(False)
oCursor.String = f'''Custom Header: '''
oCursor.gotoEnd(False)
header_content.CenterText.insertTextContent (oCursor, field_sn, True)
oCursor.gotoEnd(False)
oCursor.String = ' - ['
oCursor.gotoEnd(False)
header_content.CenterText.insertTextContent (oCursor, field_date, True)
oCursor.gotoEnd(False)
oCursor.String = ']'
return header_content
def main(*args):
doc = XSCRIPTCONTEXT.getDocument()
sheets = doc.Sheets
oSheet = sheets['mySheet1']
page_style = doc.StyleFamilies['PageStyles'][oSheet.PageStyle]
first_header = page_style.FirstPageHeaderContent
rest_header = page_style.RightPageHeaderContent
new_first_header = set_header_ctt(first_header)
page_style.FirstPageHeaderContent = new_first_header
new_rests_header = set_header_ctt(rest_header)
page_style.RightPageHeaderContent = new_rests_header
return