Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
order_unit__in=[
PRODUCT_ORDER_UNIT_LOOSE_PC, PRODUCT_ORDER_UNIT_LOOSE_KG, PRODUCT_ORDER_UNIT_LOOSE_PC_KG,
PRODUCT_ORDER_UNIT_NAMED_PC, PRODUCT_ORDER_UNIT_NAMED_KG, PRODUCT_ORDER_UNIT_NAMED_PC_KG,
PRODUCT_ORDER_UNIT_TRANSPORTATION
]
).exclude(quantity=0
).order_by(
"customer__short_basket_name",
"department_for_customer",
"long_name"
)
for purchase in purchase_set:
if ws==None:
if wb==None:
wb = Workbook()
ws = wb.get_active_sheet()
else:
ws = wb.create_sheet()
worksheet_setup_landscape_a4(ws, unicode(producer.short_profile_name) + unicode(_(" by basket")), unicode(permanence))
if basket_save != purchase.customer.short_basket_name:
basket_bold = True
if basket_save != None:
c = ws.cell(row=row_num, column=2)
c.value = unicode(_("Total Price")) + " " + basket_save
c = ws.cell(row=row_num, column=6)
formula = 'SUM(G%s:G%s)' % (row_start_sum + 2, row_num)
c.value = '=' + formula
formula_sum_sum.append(formula)
c.style.number_format.format_code = u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ '
c.style.font.bold = True
'field:id',
'field:first_name',
'field:last_name',
'field:role',
'field:email',
'field:facility_name',
'field:facility_address',
'field:phone_number',
'field:notes'
]
ordered_fields = ['_id', 'first_name', 'last_name', 'provider_title', 'email', 'facility_name', 'facility_address', 'phone_number', 'notes']
display_fields = ['id', 'first_name', 'last_name', 'role', 'email', 'facility_name', 'facility_address', 'phone_number', 'notes']
fields = set()
rows = []
wb = Workbook()
title_ws = wb.get_active_sheet()
title_ws.title = 'types'
for actor in actors_json:
#for the actors now, walk their properties and add them to the WebUser
if actor['doc_type'] == 'ProviderActor':
actor_fields = filter(lambda x: x not in exclude_fields, actor.keys())
fields.update(actor_fields)
#print actor
# for case, actors in case_provider_map.items():
# print "%s: %s" % (case, actors)
print fields
print "providers loaded, preparing data"
def export(permanence, wb=None):
if wb is None:
wb = Workbook()
ws = wb.get_active_sheet()
else:
ws = wb.create_sheet()
worksheet_setup_landscape_a4(ws, _("Planned"), permanence)
row_num = 0
if permanence.status == PERMANENCE_PLANNED:
producers_in_this_permanence = Producer.objects.filter(
permanence=permanence, is_active=True)
for product in Product.objects.filter(
producer__in=producers_in_this_permanence, is_active=True, is_into_offer=True,
translations__language_code=translation.get_language()).order_by(
"producer__short_profile_name",
"department_for_customer__tree_id",
def list_to_workbook(self, data, title='report', header=None, widths=None):
""" Create just a openpxl workbook from a list of data """
wb = Workbook()
title = re.sub(r'\W+', '', title)[:30]
if isinstance(data, dict):
i = 0
for sheet_name, sheet_data in data.items():
if i > 0:
wb.create_sheet()
ws = wb.worksheets[i]
self.build_sheet(
sheet_data, ws, sheet_name=sheet_name, header=header)
i += 1
else:
ws = wb.worksheets[0]
self.build_sheet(data, ws, header=header, widths=widths)
return wb
def export(permanence, wb=None):
translation.activate(settings.LANGUAGE_CODE)
if wb is None:
wb = Workbook()
ws = wb.get_active_sheet()
else:
ws = wb.create_sheet()
worksheet_setup_portrait_a4(ws, permanence, '')
header = [
(_("Basket"), 20),
(_('Family'), 35),
(_('Phone1'), 15),
(_('Phone2'), 15),
]
row_num = 0
worksheet_set_header(ws, header)
row_num += 1
# Customer info
#import necessary subpackages - they are small so won't matter to do it here
from openpyxl.workbook import Workbook
from openpyxl.writer.excel import ExcelWriter
from openpyxl.reader.excel import load_workbook
if not fileName.endswith('.xlsx'):
fileName+='.xlsx'
#create or load the file
if appendFile and os.path.isfile(fileName):
wb = load_workbook(fileName)
newWorkbook=False
else:
if not appendFile: #the file exists but we're not appending, so will be overwritten
if self.autoLog:
logging.warning('Data file, %s, will be overwritten' %fileName)
wb = Workbook()#create new workbook
wb.properties.creator='PsychoPy'+psychopy.__version__
newWorkbook=True
ew = ExcelWriter(workbook = wb)
if newWorkbook:
ws = wb.worksheets[0]
ws.title=sheetName
else:
ws=wb.create_sheet()
ws.title=sheetName
#loop through lines in the data matrix
for lineN, line in enumerate(dataArray):
if line==None:
continue
order_unit__in=[
PRODUCT_ORDER_UNIT_LOOSE_PC, PRODUCT_ORDER_UNIT_LOOSE_KG, PRODUCT_ORDER_UNIT_LOOSE_PC_KG,
PRODUCT_ORDER_UNIT_NAMED_PC, PRODUCT_ORDER_UNIT_NAMED_KG, PRODUCT_ORDER_UNIT_NAMED_PC_KG,
PRODUCT_ORDER_UNIT_TRANSPORTATION
]
).exclude(quantity=0
).order_by(
"department_for_customer",
"long_name",
"customer__short_basket_name"
)
for purchase in purchase_set:
if ws==None:
if wb==None:
wb = Workbook()
ws = wb.get_active_sheet()
else:
ws = wb.create_sheet()
worksheet_setup_landscape_a4(ws, unicode(producer.short_profile_name) + unicode(_(" by product")), unicode(permanence))
short_basket_name = ""
if long_name_save != purchase.long_name:
product_bold = True
row_start_sum = row_num
if department_for_customer_save != purchase.department_for_customer_id:
if department_for_customer_short_name_save != None:
row_num += 1
for col_num in xrange(7):
c = ws.cell(row=row_num, column=col_num)
c.style.borders.bottom.border_style = Border.BORDER_THIN
def list_to_workbook(self, data, title='report', header=None, widths=None):
""" Create just a openpxl workbook from a list of data """
wb = Workbook()
title = re.sub(r'\W+', '', title)[:30]
if isinstance(data, dict):
i = 0
for sheet_name, sheet_data in data.items():
if i > 0:
wb.create_sheet()
ws = wb.worksheets[i]
self.build_sheet(
sheet_data, ws, sheet_name=sheet_name, header=header)
i += 1
else:
ws = wb.worksheets[0]
self.build_sheet(data, ws, header=header, widths=widths)
return wb
def create_workbook(data, filename, headers):
wb = Workbook(optimized_write=True)
ws = wb.create_sheet()
if headers:
ws.append(headers)
for rowx, row in enumerate(data):
ws.append(map(normalize_value, list(row)))
# import pdb;pdb.set_trace()
# for colx, value in enumerate(row):
# column_letter = get_column_letter((colx + 1))
# ws.cell('%s%s'%(column_letter, (rowx+ 1))).value = value
# ws.auto_filter = ws.calculate_dimension()
wb.save(filename)