Python xlwt.Formula() Examples

The following are 7 code examples of xlwt.Formula(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module xlwt , or try the search function .
Example #1
Source File: excel_handler.py    From rotest with MIT License 7 votes vote down vote up
def _create_result_summary(self):
        """Create result summary at the end of the Excel report."""
        self.row_number += self.ROWS_TO_SKIP

        for result_type in self.CONTENT_TO_STYLE:
            self._write_to_cell(self.row_number,
                                self.SUMMARY_RESULT_TYPE_COLUMN,
                                self.CONTENT_TO_STYLE[result_type],
                                result_type)

            result_type_count = xlwt.Formula(self.FORMULA_PATTERN %
                                             (self.RESULT_COLUMN,
                                              self.RESULT_COLUMN,
                                              self.row_number,
                                              result_type))
            self._write_to_cell(self.row_number,
                                self.SUMMARY_RESULT_COUNTER_COLUMN,
                                self.DEFAULT_CELL_STYLE,
                                result_type_count)

            self.row_number += 1 
Example #2
Source File: pump.py    From pychemqt with GNU General Public License v3.0 6 votes vote down vote up
def export2xls(self):
        import xlwt
        font0 = xlwt.Font()
        font0.bold = True
        font0.height = 300
        print((font0.height))

        style0 = xlwt.XFStyle()
        style0.font = font0

        style1 = xlwt.XFStyle()
        style1.num_format_str = 'D-MMM-YY'

        wb = xlwt.Workbook()
        ws = wb.add_sheet('A Test Sheet')

        ws.write(0, 0, 'Test', style0)
        ws.write(2, 0, 1)
        ws.write(2, 1, 1)
        ws.write(2, 2, xlwt.Formula("A3+B3"))

        wb.save('datasheet.xls')
        os.system("gnumeric datasheet.xls") 
Example #3
Source File: test_simple.py    From InternationalizationScript-iOS with MIT License 6 votes vote down vote up
def create_simple_xls(self, **kw):
        font0 = xlwt.Font()
        font0.name = 'Times New Roman'
        font0.colour_index = 2
        font0.bold = True

        style0 = xlwt.XFStyle()
        style0.font = font0

        style1 = xlwt.XFStyle()
        style1.num_format_str = 'D-MMM-YY'

        wb = xlwt.Workbook(**kw)
        ws = wb.add_sheet('A Test Sheet')

        ws.write(0, 0, 'Test', style0)
        ws.write(1, 0, datetime(2010, 12, 5), style1)
        ws.write(2, 0, 1)
        ws.write(2, 1, 1)
        ws.write(2, 2, xlwt.Formula("A3+B3"))
        return wb, ws 
Example #4
Source File: test_simple.py    From InternationalizationScript-iOS with MIT License 6 votes vote down vote up
def create_simple_xls(self, **kw):
        font0 = xlwt.Font()
        font0.name = 'Times New Roman'
        font0.colour_index = 2
        font0.bold = True

        style0 = xlwt.XFStyle()
        style0.font = font0

        style1 = xlwt.XFStyle()
        style1.num_format_str = 'D-MMM-YY'

        wb = xlwt.Workbook(**kw)
        ws = wb.add_sheet('A Test Sheet')

        ws.write(0, 0, 'Test', style0)
        ws.write(1, 0, datetime(2010, 12, 5), style1)
        ws.write(2, 0, 1)
        ws.write(2, 1, 1)
        ws.write(2, 2, xlwt.Formula("A3+B3"))
        return wb, ws 
Example #5
Source File: reporting.py    From PCWG with MIT License 6 votes vote down vote up
def report(self, path, analysis, powerDeviationMatrix = True, scatterMetric=True):
        
        self.analysis = analysis
        book = xlwt.Workbook()


        sh = book.add_sheet("Anonymous Report", cell_overwrite_ok=True)
        sh.write(0, 0, "PCWG Tool Version Number:")
        sh.write(0, 1, self.version)
        sh.write(0, 2, xlwt.Formula('HYPERLINK("http://www.pcwg.org";"PCWG Website")'))
        row = 1

        if powerDeviationMatrix:
            row = self.report_power_deviation_matrix(sh,analysis,book)

        if scatterMetric:
            row = self.report_scatter_metric(sh,analysis,row, analysis.turbRenormActive)

        book.save(path) 
Example #6
Source File: test_biff_records.py    From InternationalizationScript-iOS with MIT License 5 votes vote down vote up
def test_intersheets_ref(self):
        book = xlwt.Workbook()
        sheet_a = book.add_sheet('A')
        sheet_a.write(0, 0, 'A1')
        sheet_a.write(0, 1, 'A2')
        sheet_b = book.add_sheet('B')
        sheet_b.write(0, 0, xlwt.Formula("'A'!$A$1&'A'!$A$2"))
        out = BytesIO()
        book.save(out) 
Example #7
Source File: test_biff_records.py    From InternationalizationScript-iOS with MIT License 5 votes vote down vote up
def test_intersheets_ref(self):
        book = xlwt.Workbook()
        sheet_a = book.add_sheet('A')
        sheet_a.write(0, 0, 'A1')
        sheet_a.write(0, 1, 'A2')
        sheet_b = book.add_sheet('B')
        sheet_b.write(0, 0, xlwt.Formula("'A'!$A$1&'A'!$A$2"))
        out = BytesIO()
        book.save(out)