guxingy

原文:
https://blog.csdn.net/qq_27017791/article/details/113849053

Excel格式

效果

代码

import quopri
import xlrd
 
#111.xlsx为需要处理的表格(姓名+电话)
file2=\'111.xlsx\'
 
#123.vcf 为处理后生成的文件
file1=open(\'123.vcf\',\'w+\',encoding=\'utf-8\')
 
workbook=xlrd.open_workbook(file2)
sheet=workbook.sheet_by_index(0)
n_of_rows=sheet.nrows
print(n_of_rows)
 
for i in range(n_of_rows):
    file1.write(\'BEGIN:VCARD\n\')
    file1.write(\'VERSION:2.1\n\')
    name=sheet.cell(i,0).value
    name1=\'N;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:;\'+str(quopri.decodestring(name.encode()))[2:-1].replace(\'\\x\',\'=\').upper()+\';;;\n\'
    name2=\'FN;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:;\'+str(quopri.decodestring(name.encode()))[2:-1].replace(\'\\x\',\'=\').upper()+\'\n\'
    file1.write(name1)
    file1.write(name2)
    print(\'TEL;CELL:\'+str(int(sheet.cell(i,1).value))+\'\n\')
    file1.write(\'TEL;CELL:\'+str(int(sheet.cell(i,1).value))+\'\n\')
    file1.write(\'END:VCARD\n\')
 
file1.close()


分类:

技术点:

相关文章:

  • 2021-08-05
  • 2022-12-23
  • 2021-12-31
  • 2021-04-14
  • 2021-11-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-27
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
  • 2021-11-27
  • 2021-10-16
相关资源
相似解决方案