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

石家庄做网站时光湖南网站建设推广

石家庄做网站时光,湖南网站建设推广,上海web网站建,黄色国内外网站批量新增excel文件 import osimport xlwings as xwapp xw.App(visibleTrue,add_bookFalse)#visible设置为ture的时候会自动打开创建的excel文件,设为为false的时候不会看到excel文件打开了,实际进程占用了....dept_list [人事部,财务部,研发部,行政部…
  1. 批量新增excel文件

    	import osimport xlwings  as xwapp = xw.App(visible=True,add_book=False)#visible设置为ture的时候会自动打开创建的excel文件,设为为false的时候不会看到excel文件打开了,实际进程占用了....dept_list = ['人事部','财务部','研发部','行政部']path = os.path.abspath(os.path.abspath(os.path.dirname(__file__)))dept_path = os.path.join(path,'excel文件')for dept in dept_list:workbook = app.books.add()workbook.save(f'{dept_path}/部门业绩-{dept}.xlsx')
    
  2. 批量打开excel文件

    import os
    import xlwings  as xw
    app = xw.App(visible=True,add_book=False)
    for dir,curdir,files in os.walk(dept_path):if files:for  file in files:file_path = os.path.join(dir,file)if file.endswith('.xlsx'):app.books.open(file_path)
    
  3. 批量修改excel文件工作表名

     import osimport xlwings  as xwapp = xw.App(visible=False,add_book=False)path = os.path.abspath(os.path.abspath(os.path.dirname(__file__)))dept_path = os.path.join(path,'excel文件')#批量修改  【部门业绩-行政部.xlsx  】 这个文件的工作表名workbook =app.books.open(f'{dept_path}\部门业绩-行政部.xlsx')for sheet in workbook.sheets:sheet.name = sheet.name.replace('Sheet','部门')workbook.save()app.quit()
    

4.合并相似excel文件内容到一个excel(只会合并每个excel第一个sheet页的内容)

	import pandas as pddata_list = []for dir,curdir,files in os.walk(dept_path):if files:for  file in files:file_path = os.path.join(dir,file)if file.endswith('.xlsx') and file.startswith('部门业绩-'):data_list.append(pd.read_excel(file_path))data_all = pd.concat(data_list)data_all.to_excel('部门业绩.xlsx')
  1. 合并一个excel文件多个sheet页内容到第一个sheet页中

    
    import pandas as pd
    import xlwings as xw
    file = f'{dept_path}\部门业绩-行政部.xlsx'
    df_list = pd.read_excel(file,sheet_name=None)
    df_all = pd.concat(df_list.values())
    app=xw.App(visible=False,add_book=False)
    workbook = app.books.open(file)
    workbook.sheets.add('汇总表',before=workbook.sheets[0])
    workbook.sheets['汇总表'].range('A1').options(index=False).value=df_all
    workbook.save()
    workbook.close()
    app.quit()
    
  2. 拆分excel表(按照某个分类拆分成不同的excel表)

    import pandas as pd
    file = f'{dept_path}\产品表.xlsx'
    df= pd.read_excel(file)
    products = df['产品类型'].unique()  #去重获取产品类型这一列所有产品for product in products:df_product = df[df['产品类型']==product]df_product.to_excel(f'{dept_path}\产品表-{product}.xlsx')
    
  3. 拆分excel表(按照某个分类拆分成不同的sheet页)

    import pandas as pd
    file = f'{dept_path}\采购表.xlsx'
    #读取所有sheet页
    df_list= pd.read_excel(file,sheet_name=None,parse_dates=False)
    #合并成一个大数据表
    df_all = pd.concat(df_list.values())file2 = f'{dept_path}\采购表-按产品类分.xlsx'
    excel_writer = pd.ExcelWriter(file2,date_format='YYYY-MM-DD')
    for product,df in df_all.groupby('产品类型'):df.to_excel(excel_writer,product,index=False)
    excel_writer.save()
  4. 比较2个excel文件内容

    import os
    import xlwings  as xwapp = xw.App(visible=False,add_book=False)
    file = f'{dept_path}\产品表.xlsx'
    file_back = f'{dept_path}\产品表-备份.xlsx'
    book = app.books.open(file)
    book_backup = app.books.open(file_back)for row in book.sheets[0].range('A1').expand():for cell in row:backup_cell = book_backup.sheets[0].range(cell.address)if cell.value != backup_cell.value:cell.color = backup_cell.color = (255,0,0)
    book.save()
    book.close()
    book_backup.save()
    book_backup.close()
    app.quit()
    
http://www.hengruixuexiao.com/news/12348.html

相关文章:

  • 怎么做外贸个人网站东莞网站建设推广品众
  • wordpress网站响应速度插件上海百度竞价托管
  • 网站备案 需要什么百度知道首页
  • 网页顶部导航栏武汉seo首页
  • 做网站需要几大模板seo专员很难吗
  • 做数学题网站seo成创网络
  • 网站系统建设与管理网站域名注册查询
  • 交通部的建设标准网站搜狗推广登录平台
  • 如何让搜索引擎快速收录网站行业门户网站推广
  • 连云港市建设局网站门户网站推广方案
  • 备案网站资料上传教程百度云建站
  • 苏州做网站优化哪家好seo工具网站
  • 用dw设计最简单的网页谈谈你对seo概念的理解
  • 网站建设的技术风险分析与规避优化网络软件
  • 广州网站优化快速获取排名企业宣传推广
  • 个人做网站设计市场营销策划方案
  • 遵义 网站建设销售系统
  • 深圳专业营销网站公司提高百度搜索排名工具
  • 山东济南网站开发网站seo关键词优化
  • wordpress自动设置特色图像长沙seo优化排名
  • wordpress启用多站点和子站独立域名绑定后设置高质量内容的重要性
  • 武汉个人做网站的电话app开发公司排名
  • 网站建设一个人东莞seo建站咨询
  • wordpress 主题不显示郑州seo外包平台
  • 内容管理系统设计百度seo公司哪家好一点
  • 靠比较软件下载网站自己怎么做网址开网站
  • 凡科电脑版登录首页seo这个职位是干什么的
  • 小红书app是哪家公司开发的谷歌seo博客
  • 做美女写真网站犯法吗正规的培训学校
  • 有关于做茗茶的网站佛山seo优化外包