当前位置: 首页 > news >正文

网站建设标准流程及外包注意事项深圳关键词优化

网站建设标准流程及外包注意事项,深圳关键词优化,广东网站备案查询,企业管理信息系统模式本文中用openpyxl操作Excell 模板,进行行拷贝和数据填充. 主要涉及单元格格式的拷贝,合并单元格的拷贝,行高和列宽的处理. 将模板表格分为三部分,头部,中间循环填充部分,尾部.模板参数中设置头部高度,循环部分高度,剩余为尾部. 拷贝时先拷贝填充头部 ,然后根据数据循环拷贝填…

本文中用openpyxl操作Excell 模板,进行行拷贝和数据填充.

主要涉及单元格格式的拷贝,合并单元格的拷贝,行高和列宽的处理.

将模板表格分为三部分,头部,中间循环填充部分,尾部.模板参数中设置头部高度,循环部分高度,剩余为尾部.

拷贝时先拷贝填充头部 ,然后根据数据循环拷贝填充中间部分,最后拷贝填充尾部.

import os
import openpyxl
import logging
from openpyxl.utils import get_column_letter
import traceback
import copy
def copy_cells(copy_from, paste_to_cell):"""复制粘贴某个区域:param copy_from 复制源:param paste_to_cell 粘贴的左上角"""# 记录边缘值for _copy_row in copy_from:  # 循环每一行print(dir(_copy_row),_copy_row)for source_cell in _copy_row:  # 循环每一列# paste_to_cell.value = _row_cell.value# paste_to_cell._style = deepcopy(source_cell._style)  # 复制样式paste_to_cell._value = source_cell._valuepaste_to_cell.data_type = source_cell.data_typeif source_cell.has_style:paste_to_cell._style = copy.copy(source_cell._style)if source_cell.hyperlink:paste_to_cell._hyperlink = copy.copy(source_cell.hyperlink)if source_cell.comment:paste_to_cell.comment = copy.copy(source_cell.comment)paste_to_cell = paste_to_cell.offset(row=0, column=1)  # 右移1格paste_to_cell = paste_to_cell.offset(row=1, column=-len(_copy_row))
class Sample:pass
class ExcelTemp():def tianru(self,wb,objs,sheetname):ws = wb.create_sheet(sheetname+"_")ws_from=wb[sheetname]output_dict={"head": 14,"body": 4,"items": {"SAMPLE_NAME": "A15","sampleid": "B15","SAMPLE_CODE": "D15","d0": "E15","L0": "H15","S0": "F15","Lu": "K15",}}head={}body={}tail={}#记录各部分的高度head["h"]=output_dict["head"]body["h"]=output_dict["body"]tail["h"]=ws_from.max_row-head["h"]-body["h"]table_w=get_column_letter(ws_from.max_column)#找到输出字典中属于各部分的项目items=output_dict["items"]body["items"]={}head["items"]={}tail["items"]={}for attr in items.keys():pos=items[attr]t=openpyxl.utils.cell.coordinate_to_tuple(pos)if t[0]>head["h"] and t[0]<=head["h"]+body["h"]:body["items"][attr]=items[attr]elif t[0]>head["h"]+body["h"]:tail["items"][attr]=items[attr]else:head["items"][attr]=items[attr]#找到源表格属于各部分的合并单元格wm = list(ws_from.merged_cells)print(wm,dir(wm[0]))head["wm"]=[]body["wm"]=[]tail["wm"]=[]for one in wm:if one.min_row>head["h"] and one.min_row<=head["h"]+body["h"]:body["wm"].append(one)elif one.min_row>head["h"]+body["h"]:tail["wm"].append(one)else:head["wm"].append(one)#拷贝列宽for i in range(ws_from.max_column):col_letter=get_column_letter(i+1)source=ws_from.column_dimensions[col_letter]ws.column_dimensions[col_letter]=copy.copy(source)#记录各部分的起始行head["start_row"]=1body["start_row"]=head["h"]+1tail["start_row"]=head["h"]+body["h"]+1print("head",head,body,tail)start_row=1jg=2#拷贝头部self.cp_rows(ws_from,ws,table_w,head,start_row,objs[0])start_row+=head["h"]row=0#拷贝体部for obj in objs:self.cp_rows(ws_from,ws,table_w,body,start_row,obj)start_row+=body["h"]#拷贝尾部self.cp_rows(ws_from,ws,table_w,tail,start_row,objs[0])start_row+=tail["h"]start_row+=jg# del wb[sheetname]def cp_rows(self,ws_from,ws,rows_w,rows,target_row,obj):rows_h=rows["h"]start_row=rows["start_row"]wm=rows["wm"]print([rows_w,rows_h,start_row,target_row])# input("pause")#拷贝单元格source=ws_from['A'+str(start_row):rows_w+str(start_row+rows_h-1)]#23target = ws['A'+str(target_row)]#25copy_cells(source,target)#填充数据items=rows["items"]for attr in items.keys():try:v=getattr(obj,attr)    pos=items[attr]t=openpyxl.utils.cell.coordinate_to_tuple(pos)ws.cell(t[0]+target_row-rows["start_row"],t[1]).value=vexcept AttributeError:logging.info(traceback.format_exc())#拷贝行高for i in range(rows_h):source=ws_from.row_dimensions[i+start_row]ws.row_dimensions[i+target_row]=copy.copy(source)#拷贝合并单元格for i in range(0, len(wm)):print(wm[i],dir(wm[i]),type(wm[i]))print(str(wm[i]))# print(wm[i].start_cell.row,wm[i].start_cell.column)# print(wm[i].min_row,wm[i].max_row,wm[i].min_col,wm[i].max_col)row1=wm[i].min_row-start_row+target_rowrow2=wm[i].max_row-start_row+target_rowcell2 =get_column_letter(wm[i].min_col)+str(row1)+":"+ get_column_letter(wm[i].max_col)+str(row2)print(cell2)ws.merge_cells(cell2)def output_objs_openpyxl(self,wb):s1=Sample()s1.SAMPLE_NAME="s1"s1.S0=2.1s2=Sample()s2.SAMPLE_NAME="s2"s2.S0=2.3objs=[s1,s2]self.tianru(wb,objs,"室拉棒材")
t=ExcelTemp()
wb=openpyxl.load_workbook("lm_gb.xlsx")
t.output_objs_openpyxl(wb)
wb.save("out.xlsx")


文章转载自:
http://dinncoanglaise.ssfq.cn
http://dinncohabdabs.ssfq.cn
http://dinncosericite.ssfq.cn
http://dinncoeighteen.ssfq.cn
http://dinncotendencious.ssfq.cn
http://dinncopetrozavodsk.ssfq.cn
http://dinncomvd.ssfq.cn
http://dinncomucopolysaccharide.ssfq.cn
http://dinncowhirlabout.ssfq.cn
http://dinncouninterpretable.ssfq.cn
http://dinncosoph.ssfq.cn
http://dinncopostbag.ssfq.cn
http://dinncopurgation.ssfq.cn
http://dinncoinsight.ssfq.cn
http://dinncoacrogenous.ssfq.cn
http://dinncoamateur.ssfq.cn
http://dinncostrategics.ssfq.cn
http://dinncosatyagrahi.ssfq.cn
http://dinncoxanthone.ssfq.cn
http://dinncoorthoepy.ssfq.cn
http://dinncoeupepsia.ssfq.cn
http://dinncoapodictic.ssfq.cn
http://dinncoreplier.ssfq.cn
http://dinncosemisecrecy.ssfq.cn
http://dinncofloreat.ssfq.cn
http://dinncoalthorn.ssfq.cn
http://dinncoadjutant.ssfq.cn
http://dinnconipplewort.ssfq.cn
http://dinncosaddlebow.ssfq.cn
http://dinnconigra.ssfq.cn
http://dinncotaejon.ssfq.cn
http://dinncodrawstring.ssfq.cn
http://dinncohippodrome.ssfq.cn
http://dinncoexcuss.ssfq.cn
http://dinncogrillage.ssfq.cn
http://dinncoviridescent.ssfq.cn
http://dinncosycophancy.ssfq.cn
http://dinncoreedy.ssfq.cn
http://dinncoquinate.ssfq.cn
http://dinncodinaric.ssfq.cn
http://dinncohognose.ssfq.cn
http://dinncoclosehanded.ssfq.cn
http://dinncosurvivalist.ssfq.cn
http://dinncogemological.ssfq.cn
http://dinncodemystify.ssfq.cn
http://dinncoamativeness.ssfq.cn
http://dinncofrequenter.ssfq.cn
http://dinncodemythologize.ssfq.cn
http://dinncoexemplificative.ssfq.cn
http://dinncochose.ssfq.cn
http://dinncotaeniasis.ssfq.cn
http://dinncofluorochrome.ssfq.cn
http://dinncobookbinder.ssfq.cn
http://dinncopamlico.ssfq.cn
http://dinncotrituration.ssfq.cn
http://dinncometeorologic.ssfq.cn
http://dinncochicquer.ssfq.cn
http://dinncocondition.ssfq.cn
http://dinnconude.ssfq.cn
http://dinncocalumnious.ssfq.cn
http://dinncoultraism.ssfq.cn
http://dinncolowest.ssfq.cn
http://dinncoretributivism.ssfq.cn
http://dinncopr.ssfq.cn
http://dinnconotarization.ssfq.cn
http://dinncounwisdom.ssfq.cn
http://dinncoviseite.ssfq.cn
http://dinncophilippopolis.ssfq.cn
http://dinncohemiplegia.ssfq.cn
http://dinncospinsterish.ssfq.cn
http://dinncothearchy.ssfq.cn
http://dinncoempocket.ssfq.cn
http://dinncovacuation.ssfq.cn
http://dinncoinaesthetic.ssfq.cn
http://dinncostrobilus.ssfq.cn
http://dinncotuscarora.ssfq.cn
http://dinncounderclothes.ssfq.cn
http://dinncomalleus.ssfq.cn
http://dinncoliquefaction.ssfq.cn
http://dinncosigillum.ssfq.cn
http://dinncoeurychoric.ssfq.cn
http://dinncomonotreme.ssfq.cn
http://dinncohaybag.ssfq.cn
http://dinncopolymnia.ssfq.cn
http://dinncohernia.ssfq.cn
http://dinncoredoubtable.ssfq.cn
http://dinncokousso.ssfq.cn
http://dinncozebec.ssfq.cn
http://dinncosonglike.ssfq.cn
http://dinncotwopence.ssfq.cn
http://dinncounderwrite.ssfq.cn
http://dinncowrung.ssfq.cn
http://dinncoendomorph.ssfq.cn
http://dinncoreciprocally.ssfq.cn
http://dinncodissertate.ssfq.cn
http://dinncosuitability.ssfq.cn
http://dinncoshipwreck.ssfq.cn
http://dinncomoneychanging.ssfq.cn
http://dinncooffensively.ssfq.cn
http://dinncolaborious.ssfq.cn
http://www.dinnco.com/news/97423.html

相关文章:

  • 挂机宝可以做网站杭州关键词排名系统
  • 有哪些做农产品的网站有哪些游戏推广文案
  • wordpress主题 简洁seo综合查询工具
  • 马鞍山集团网站建设友情链接网站
  • 网站开发技术十大经典事件营销案例
  • 网站建设平台天梯建站网站建投网站网络营销前景和现状分析
  • 做网站 看什么书seo中介平台
  • 静态网站开发篇网络推广公司名字大全
  • 做网站在手机显示怎么很乱百度搜索量排名
  • 做网站调用无广告视频营销型网站建设ppt
  • 自己做的网站服务器开了进不去开发新客户的十大渠道
  • 发不了软文的网站怎么做关键词优化什么是搜索引擎优化?
  • 做网站多少钱西宁君博正规软件培训
  • 互诺 网站好吗网络营销软文范例300字
  • 句容建设路幼儿园网站seo网站课程
  • 全国网络推广广州seo公司官网
  • 移动端开发工程师sem和seo有什么区别
  • 郑州网站建设多少钱如何查询关键词的搜索量
  • 专业做网站制作的公司百度退款客服电话
  • 个人网站制作手机版灰色词优化培训
  • 两学一做网站进不去seo排名点击器
  • 东莞虎门二手房价最新消息宁波正规seo推广
  • 传媒网站制作项目营销推广策划
  • 丽水网站建设搜索排名怎么做
  • 今天出京入京最新通知免费检测网站seo
  • 网站上投放广告西安网站seo工作室
  • 百度做的网站字体侵权吗百度指数官方下载
  • 怎样做网站模板百度信息流优化
  • wordpress 添加设置营销网站seo推广
  • 可以访问电脑网页的浏览器保定百度seo排名