Re: Renaming Excel Spreadsheets

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Emile van Sebille

    Re: Renaming Excel Spreadsheets

    Greg Lindstrom wrote:
    Hello,
    >
    I am working with Python to create Excel spreadsheets and have run into
    a couple of problems I hope you can help me with.
    >
    First...are there any bindings/libraries into Open Office?
    >
    Now, back to Excel.
    >
    --Does anyone know a way to create N worksheets? By default, 3 are
    created, but I would like more.
    >
    --Is it possible to rename a worksheet inside of the workbook (change
    "Sheet1" to "July 08", for example).
    Here's some code from years back that adds sheets to a workbook and then
    renames them.

    Sheets = [["SlsSrce",None, 1],
    ["SalesReps",Non e,1],
    ["Control",None, 1]]

    replist = []
    for k in repkeys:
    if k in currentReps:
    replist.append([k, reps[k]])
    Sheets.append(['Rep-%s' % k, None, 1])

    def WorkBookSetup(S heets):
    # xl.Visible = 1
    wbi = xl.Workbooks.Ad d()
    wbi.Activate()
    sheetcount = xl.Sheets.Count
    index = 0
    for name, ref, nextline in Sheets:
    if index >= sheetcount:
    wbi.Sheets.Add( )
    index = index + 1
    index = 0
    for name, ref, nextline in Sheets:
    wbi.Sheets[index].Name = name
    Sheets[index][1] = wbi.Sheets[index]
    index = index + 1
    return wbi

    HTH,

    Emile

Working...