Esempio n. 1
0
def getDefualtStyle():
	fnt = Font()
	fnt.name = 'Arial'
	
	borders = Borders()
	borders.left = Borders.THIN
	borders.right = Borders.THIN
	borders.top = Borders.THIN
	borders.bottom = Borders.THIN
	
	#pattern = Pattern()
	#pattern.pattern = Style.pattern_map['solid']
	###pattern.pattern_back_colour = 0xBFBFBF
	#pattern.pattern_fore_colour = 0x37
	
	
	alignment = Alignment()
	#alignment.horizontal = Alignment.HORZ_LEFT 
	alignment.horizontal = Alignment.HORZ_RIGHT
	
	
	style = XFStyle()
	#~ style.num_format_str='0.000%'
	#~ style.num_format_str='0+'
	#~ style.font = fnt
	style.align = alignment
	style.borders = borders
	#~ style.pattern = pattern
	
	return style
Esempio n. 2
0
def getDefualtStyle():
	fnt = Font()
	fnt.name = 'Arial'
	
	borders = Borders()
	borders.left = Borders.THIN
	borders.right = Borders.THIN
	borders.top = Borders.THIN
	borders.bottom = Borders.THIN
	
	#pattern = Pattern()
	#pattern.pattern = Style.pattern_map['solid']
	###pattern.pattern_back_colour = 0xBFBFBF
	#pattern.pattern_fore_colour = 0x37
	
	
	alignment = Alignment()
	#alignment.horizontal = Alignment.HORZ_LEFT 
	alignment.horizontal = Alignment.HORZ_RIGHT
	
	
	style = XFStyle()
	#~ style.num_format_str='0.000%'
	#~ style.num_format_str='0+'
	#~ style.font = fnt
	style.align = alignment
	#style.borders = borders
	#~ style.pattern = pattern
	
	return style
Esempio n. 3
0
    def exportToXls(self):
        # opening file dialog
        fileName = QFileDialog.getSaveFileName(self,
            'Save as', RES, 'Microsoft Excel Spreadsheet (*.xls)')

        if fileName.count() > 0:
            try:
                COLUMN_WIDTH = 3000

                alignment = Alignment()
                alignment.horizontal = Alignment.HORZ_CENTER
                alignment.vertical = Alignment.VERT_CENTER

                borders = Borders()
                borders.left = Borders.THIN
                borders.right = Borders.THIN
                borders.top = Borders.THIN
                borders.bottom = Borders.THIN

                style = XFStyle()
                style.alignment = alignment
                style.borders = borders

                font = Font()
                font.bold = True
                headerStyle = XFStyle()
                headerStyle.font = font

                separate = Borders()
                separate.left = Borders.THIN
                separate.right = Borders.DOUBLE
                separate.top = Borders.THIN
                separate.bottom = Borders.THIN
                separateStyle = XFStyle()
                separateStyle.borders = separate

                book = Workbook(encoding='utf-8')

                # modelling data
                dec_sheet = book.add_sheet('Data decomposition')

                # decomposition data
                # initial data
                column = 0
                row = 0
                dec_sheet.write(row, column, 'Time series', headerStyle)
                dec_sheet.col(column).width = COLUMN_WIDTH
                row += 1
                for item in self.data[0]:
                    dec_sheet.write(row, column, item, separateStyle)
                    row += 1

                # decomposition
                for lvl in self.wCoefficients:
                    row = 0
                    column += 1
                    dec_sheet.write(row, column, 'Level' + str(column - 1), headerStyle)
                    dec_sheet.col(column).width = COLUMN_WIDTH
                    row += 1
                    for item in lvl:
                        dec_sheet.write(row, column, item, style)
                        row += 1

                # decomposition graphs
                pass

                levels_sheet = book.add_sheet('Multiscale forecast')

                # levels data
                column = 0
                for lvl in self.forecast:
                    row = 0
                    levels_sheet.write(row, column, 'Level' + str(column), headerStyle)
                    levels_sheet.col(column).width = COLUMN_WIDTH
                    row += 1
                    for item in lvl[1]:
                        levels_sheet.write(row, column, float(item), style)
                        row += 1
                    column += 1

                result_sheet = book.add_sheet('Results')

                # initial
                column = 0
                row = 0
                result_sheet.write(row, column, 'Initial data', headerStyle)
                result_sheet.col(column).width = COLUMN_WIDTH
                row += 1
                for item in self.data[0]:
                    result_sheet.write(row, column, item, separateStyle)
                    row += 1

                # forecast
                row = 0
                column += 1
                result_sheet.write(row, column, 'Forecast', headerStyle)
                result_sheet.col(column).width = COLUMN_WIDTH
                row += 1
                for item in self.inverseWT():
                    result_sheet.write(row, column, item, style)
                    row += 1

                row = 0
                column = 2
                self.updateGraph()
                self.plotResult.saveFigure('forecast', format='bmp')

                result_sheet.insert_bitmap(RES + TEMP + 'forecast.bmp', row, column)

                # saving xls
                try:
                    book.save(unicode(fileName))
                except Exception:
                    pass

            except Exception, e:
                pass
Esempio n. 4
0
    def exportToXls(self):
        # opening file dialog
        fileName = QFileDialog.getSaveFileName(self, "Save as", RES, "Microsoft Excel Spreadsheet (*.xls)")

        if fileName.count() > 0:
            try:
                COLUMN_WIDTH = 3000

                alignment = Alignment()
                alignment.horizontal = Alignment.HORZ_CENTER
                alignment.vertical = Alignment.VERT_CENTER

                borders = Borders()
                borders.left = Borders.THIN
                borders.right = Borders.THIN
                borders.top = Borders.THIN
                borders.bottom = Borders.THIN

                style = XFStyle()
                style.alignment = alignment
                style.borders = borders

                font = Font()
                font.bold = True
                headerStyle = XFStyle()
                headerStyle.font = font

                separate = Borders()
                separate.left = Borders.THIN
                separate.right = Borders.DOUBLE
                separate.top = Borders.THIN
                separate.bottom = Borders.THIN
                separateStyle = XFStyle()
                separateStyle.borders = separate

                book = Workbook(encoding="utf-8")

                # modelling data
                if self.exportStepByStep.isChecked():
                    dec_sheet = book.add_sheet("Data decomposition")

                    # decomposition data
                    if self.exportData.isChecked():
                        # initial data
                        column = 0
                        row = 0
                        dec_sheet.write(row, column, "Time series", headerStyle)
                        dec_sheet.col(column).width = COLUMN_WIDTH
                        row += 1
                        for item in self.parentWidget().currentDataSet[0]:
                            dec_sheet.write(row, column, item, separateStyle)
                            row += 1

                        # decomposition
                        for lvl in self.parentWidget().wCoefficients:
                            row = 0
                            column += 1
                            dec_sheet.write(row, column, "Level" + str(column - 1), headerStyle)
                            dec_sheet.col(column).width = COLUMN_WIDTH
                            row += 1
                            for item in lvl:
                                dec_sheet.write(row, column, item, style)
                                row += 1

                    # decomposition graphs
                    if self.exportGraph.isChecked():
                        pass

                    levels_sheet = book.add_sheet("Multiscale forecast")

                    # levels data
                    if self.exportData.isChecked():
                        column = 0
                        for lvl in self.parentWidget().processedWCoeffs:
                            row = 0
                            levels_sheet.write(row, column, "Level" + str(column), headerStyle)
                            levels_sheet.col(column).width = COLUMN_WIDTH
                            row += 1
                            for item in lvl:
                                levels_sheet.write(row, column, float(item), style)
                                row += 1
                            column += 1

                if self.exportForecast.isChecked():
                    result_sheet = book.add_sheet("Results")

                    if self.exportData.isChecked():
                        # initial
                        column = 0
                        row = 0
                        result_sheet.write(row, column, "Initial data", headerStyle)
                        result_sheet.col(column).width = COLUMN_WIDTH
                        row += 1
                        for item in self.parentWidget().currentDataSet[0]:
                            result_sheet.write(row, column, item, separateStyle)
                            row += 1

                        # forecast
                        row = 0
                        column += 1
                        result_sheet.write(row, column, "Forecast", headerStyle)
                        result_sheet.col(column).width = COLUMN_WIDTH
                        row += 1
                        for item in self.parentWidget().resultingForecast:
                            result_sheet.write(row, column, item, style)
                            row += 1

                    if self.exportGraph.isChecked():
                        row = 0
                        column = 2
                        self.parentWidget().resultingGraph.saveFigure("forecast", format="bmp")

                        result_sheet.insert_bitmap(RES + TEMP + "forecast.bmp", row, column)

                # saving xls
                try:
                    book.save(unicode(fileName))
                    self.parentWidget().messageInfo.showInfo("Saved as " + unicode(fileName))
                except Exception:
                    self.parentWidget().messageInfo.showInfo("Could not save as " + unicode(fileName), True)

            except Exception, e:
                self.parentWidget().messageInfo.showInfo("Not enough data.", True)