2011-12-21 13 views
4

Pythonとxlwtを使用してExcelで列の値が変更されるたびに改ページを追加しようとしています。xlwt - 改ページをExcelファイルに追加するには?

誰でもこれを行う方法を知っていますか?

は私が one exampleを見つけましたが、そのコードが動作するかどうか彼らは本当に言っていない、と彼らは数字がタプルに何を意味するのか言っていない:Excelのフォーマットを記述する私は this OpenOffice.org documentを発見したいくつかのウェブ調査を行う

ws.horz_page_breaks = [(54, 0, 255), (108, 0, 255)] 
+0

まあ、遊んだ後、各タプルの最初の数字は行番号のように見えます。私は他の数字が何であるか分かりません。助けて! – Greg

+0

回答ありがとうございます。好奇心が強い人は、カラムの値が変わるたびにページ区切りを挿入するための簡単なユーティリティを作成しました:http://utilitymill.com/utility/excel_page_breaks_at_col_value_change(「ソースを表示」リンクをクリックすると、コードを見ることができますそれを行うには) – Greg

+0

xlwtを使用してページ区切りの同じ問題に直面しています。あなたのリンクにはauthanticationが必要です –

答えて

5

およびBIFF記録。 (PAG 181)は水平ブレークのためと思われる、各タプルは表す:ページの最後の列に改ページ

  • インデックスの最初の列に改ページ
  • ランキング下の最初の行に

    • インデックスだから、あなたが質問に表示たとえば、あなたがそれらの両方が列0から列にまたがる、2つの改ページ、行54分の1と行108の上に別のものを持っている

    を破る255

    垂直ブレイクにも同じことが適用されます。前述の「行」と「列」を入れ替えてください。 xlwtのソースコードで掘る

  • 2

    、それは{vert,horiz}_page_breaksBIFFRecords.{Vertical,Horizontal}PageBreaksRecordに渡されてしまう性質(ソース分布のWorksheet.pyを参照)(BIFFRecords.py参照)が判明しました。最後の2つのクラスと記載されています。

    class HorizontalPageBreaksRecord(BiffRecord): 
        """ 
        This record is part of the Page Settings Block. It contains all 
        horizontal manual page breaks. 
    
        Record HORIZONTALPAGEBREAKS, BIFF8: 
        Offset Size Contents 
        0  2  Number of following row index structures (nm) 
        2  6nm List of nm row index structures. Each row index 
            structure contains: 
            Offset Size Contents 
            0  2  Index to first row below the page break 
            2  2  Index to first column of this page break 
            4  2  Index to last column of this page break 
    
        The row indexes in the lists must be ordered ascending. 
        If in BIFF8 a row contains several page breaks, they must be ordered 
        ascending by start column index. 
        """ 
    
    class VerticalPageBreaksRecord(BiffRecord): 
        """ 
        This record is part of the Page Settings Block. It contains all 
        vertical manual page breaks. 
    
        Record VERTICALPAGEBREAKS, BIFF8: 
        Offset Size Contents 
        0  2  Number of following column index structures (nm) 
        2  6nm List of nm column index structures. Each column index 
            structure contains: 
            Offset Size Contents 
            0  2  Index to first column following the page 
                break 
            2  2  Index to first row of this page break 
            4  2  Index to last row of this page break 
    
        The column indexes in the lists must be ordered ascending. 
        If in BIFF8 a column contains several page breaks, they must be ordered 
        ascending by start row index. 
        """ 
    
    関連する問題