How Do I Bold only part of a string in an excel cell with python -



How Do I Bold only part of a string in an excel cell with python -

i'm using win32com fill out excel spreadsheet analytic information. have cell want in form:

this problem description: command run prepare

i can't seem figure out how text cell python mixed formatting.

import win32com.client win32 excel = win32.gencache.ensuredispatch('excel.application') wb = excel.workbooks.add() ws = wb.worksheets("sheet1") excel.visible=true sel = excel.selection sel.value = "this command run prepare it" sel.font.bold = true ws.cells(1,1).value = 'this problem description' + sel.value #makes whole cell bold ws.cells(1,1).value = "{} {}".format("this problem desc",sel) #makes whole cell bold

the selection object has characters attribute, can't find documentation on does. i'm @ bit of loss here, utilize assist.

thanks

i found it, posting here our stack overflow overlords can have reply on hand well.

per @ron-rosenfield, vba code pull off looks like:

range("a1").characters(2,5).font.bold = true

and similarly, there characters object attribute of excel worksheet's range

>>> ws.range("a1").characters <win32com.gen_py.microsoft excel 14.0 object library.characters 967192>

however, method need access range object getcharacters(start, length) (index starts @ 1 per usual excel com methods)

ws.range("a1").getcharacters(2,4).font.bold = true

you can utilize command update boldness of characters in cell after fact.

python excel formatting win32com

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -