Beispiel #1
0
    def write_xls_price(self):
        if self.options['whole']:
            filename = path.join(settings.MEDIA_ROOT, 'upload/wprice.xls')
        else:
            filename = path.join(settings.MEDIA_ROOT, 'upload/price.xls')
        workBookDocument = Workbook()
        docSheet = workBookDocument.add_sheet(u'Прайс соло-парфюм')
        docSheet.col(1).width = 10000
        headerFont = Font()
        headerFont.bold = True
        headerFont.size = 400
        headerStyle = XFStyle()
        headerStyle.font = headerFont
        docSheet.row(0).set_style(headerStyle)
        if self.options['whole']:
            docSheet.write_merge(
                0, 0, 0, 2, u'Оптовый прайс-лист Соло-парфюм (%s)' %
                datetime.now().strftime('%d.%m.%Y'))
        else:
            docSheet.write_merge(
                0, 0, 0, 2, u'Прайс-лист Соло-парфюм (%s)' %
                datetime.now().strftime('%d.%m.%Y'))

        docSheet.write(2, 0, u'Артикул')
        docSheet.write(
            2,
            1,
            u'Наименование',
        )
        docSheet.write(2, 2, u'Цена')

        sectionFont = Font()
        sectionFont.bold = True
        sectionStyle = XFStyle()
        sectionStyle.font = sectionFont
        align = Alignment()
        align.horz = Alignment.HORZ_CENTER
        sectionStyle.alignment = align

        row = 3
        for section in self.data.iterkeys():
            docSheet.write_merge(row, row, 0, 2, section, sectionStyle)
            row += 1
            for item in self.data[section]:
                docSheet.write(row, 0, item['identifier'])
                docSheet.write(row, 1, item['name'])
                docSheet.write(row, 2, item['price'])
                row += 1

        workBookDocument.save(filename)
Beispiel #2
0
def returnStyle():
    borders = Borders()
    borders.left = 0
    borders.right = 0
    borders.top = 0
    borders.bottom = 0
    #borders.Font.Size = 10
    borders.Font = "10"

    al = Alignment()
    al.horz = Alignment.HORZ_CENTER
    al.vert = Alignment.VERT_CENTER

    style = XFStyle()
    style.borders = borders
    style.alignment = al
    return style
Beispiel #3
0
    def write_xls_price(self):
        if self.options['whole']:
            filename = path.join(settings.MEDIA_ROOT, 'upload/wprice.xls')
        else:
            filename = path.join(settings.MEDIA_ROOT, 'upload/price.xls')
        workBookDocument = Workbook()
        docSheet = workBookDocument.add_sheet(u'Прайс соло-парфюм')
        docSheet.col(1).width = 10000
        headerFont = Font()
        headerFont.bold = True
        headerFont.size = 400
        headerStyle = XFStyle()
        headerStyle.font = headerFont
        docSheet.row(0).set_style(headerStyle)
        if self.options['whole']:
            docSheet.write_merge(0, 0, 0, 2, u'Оптовый прайс-лист Соло-парфюм (%s)' % datetime.now().strftime('%d.%m.%Y'))
        else:
            docSheet.write_merge(0, 0, 0, 2, u'Прайс-лист Соло-парфюм (%s)' % datetime.now().strftime('%d.%m.%Y'))

        docSheet.write(2, 0, u'Артикул')
        docSheet.write(2, 1, u'Наименование', )
        docSheet.write(2, 2, u'Цена')

        sectionFont = Font()
        sectionFont.bold = True
        sectionStyle = XFStyle()
        sectionStyle.font = sectionFont
        align = Alignment()
        align.horz = Alignment.HORZ_CENTER
        sectionStyle.alignment = align

        row = 3
        for section in self.data.iterkeys():
            docSheet.write_merge(row, row, 0, 2, section, sectionStyle)
            row += 1
            for item in self.data[section]:
                docSheet.write(row, 0, item['identifier'])
                docSheet.write(row, 1, item['name'])
                docSheet.write(row, 2, item['price'])
                row += 1

        workBookDocument.save(filename)
Beispiel #4
0
borders.left = 1
borders.right = 1
borders.top = 1
borders.bottom = 1

align = Alignment()
align.horz = Alignment.HORZ_CENTER
align.vert = Alignment.VERT_CENTER

style = XFStyle()
style.borders = borders

# center style
cs = XFStyle()
cs.borders = borders
cs.alignment = align

date_fmt = '%Y-%m-%d'
time_fmt = '{:02d}:00 - {:02d}:00'
st_fmt = '%Y-%m-%d %H:%M:%S'


def get_dept_ids():
    data = dict()
    for dp in depts:
        spec = dict(name=dp)
        data[dp] = [o['_id'] for o in db.departments.find(spec)]

    return data

Beispiel #5
0
    def setup_timetable_worksheet(self,title,base_offsets,maxcells):
        h1 = []
        h2 = []
        h1.append(title)
        h2.extend(['Monday','Tuesday','Wednesday','Thursday','Friday'])
        labels = ['1st period','2nd period','3rd period','4th period','5th period']
        
        times = ['(8:45 - 10:15)','(10:30 - 12:00)','(13:00 - 14:30)','(14:45 - 16:15)','(16:30 - 18:00)']

        h1Style = XFStyle()
        
        font = Font()
        font.height = 300
        font.bold = True
        
        align = Alignment()
        align.horz = Alignment.HORZ_CENTER
        
        h1Style.font = font
        h1Style.alignment = align
        
        h2Style = XFStyle()
        align = Alignment()
        align.rota = 30
        align.horz = Alignment.HORZ_CENTER
        align.vert = Alignment.VERT_CENTER
        h2Style.alignment = align

        borders = Borders()
        borders.bottom = Borders.THIN
        h2Style.borders = borders        
        
        labelStyle = XFStyle()
        borders = Borders()
        borders.bottom = Borders.THIN
        borders.top = Borders.THIN
        borders.left = Borders.THIN
        borders.right = Borders.THIN
        labelStyle.borders = borders
        
        align = Alignment()
        align.rota = 90
        align.horz = Alignment.HORZ_CENTER
        align.vert = Alignment.VERT_CENTER
        labelStyle.alignment = align
            


        self.ws.write_merge(0,0,0,5,title,h1Style)
        
        for pos in range (0,5,1):
            self.ws.write(1,pos+1,h2[pos],h2Style)
        self.ws.write(1,0,'',h2Style)
        for pos in range(0,5,1):
            base_offset = base_offsets[pos]
            offset = maxcells[pos]

            for r in range(2+base_offset,2+base_offset+offset,1):
                row = self.ws.row(r)
                row.height = 5000/offset
                #row.has_default_height = False
            
            text = '%s\n%s' % (labels[pos],times[pos])
            print "base_offset: %d" % (base_offset,)
            print "offset: %d" % (offset,)
            self.ws.write_merge(2+base_offset,2+base_offset+offset-1,0,1,text,labelStyle)
            #self.ws.write_merge(2+base_offset,2+base_offset+offset,0,0,text,labelStyle)

        self.ws.col(0).width = 1200
        for pos in range(1,6,1):    
            self.ws.col(pos).width = 5500

        #self.ws.row(10).has_default_height = False
        self.ws.row(10).height = 400