码迷,mamicode.com
首页 > 其他好文 > 详细

导出文件——实现方法汇总

时间:2020-03-30 21:52:44      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:mem   net   nload   business   动态   enc   nbsp   否则   import   

需求:

1.简单导出数据;

2.导出数据与图片;

3.自动分页,设置标题;

4.设置文件名等

 【原理】:

根据需要导出的内容格式进行设计模板,简单的文件格式如txt、doc,输出带换行符的字符串;如果是输出excel格式,需要借助xls插件,设计excel数据模板,如下:

1.【模板字符串】:

xxx, xxx \n
xxx, xxx \n
...

2.【excel格式模板对象】:范围+内容,合并2个对象即可:

Object.assign(headerObj,contentObj)

得到的格式模板如下:

{
!ref: "A1:Xn" A1: {v: "标题A1"} A2: {v: "内容A2"} ... B1: {v: "标题B1"}
...
Xn: {v:"标题Xn"}
}

难点是字符如何输出:

String.fromCharCode(65,66,67) // A,B,C
// 输出xls格式对象
const getXlsData = (arr) => {
  const contentObj = {} // 生成表内数据
  let max = A1
  arr.forEach((val, ind) => { // 多维数组
    val.forEach((item, index) => {
      max = String.fromCharCode(65 + index) + (ind + 1)
      contentObj[max] = { v: item }
    })
  })
  const headerObj = {!ref: A1: + max}// 生成表头
  return Object.assign(headerObj, contentObj)
}
// 输出字母顺序
const getCharCol = (n) => {
  let s = ‘‘
  let m = 0
  while (n > 0) {
    m = n % 26 + 1
    s = String.fromCharCode(m + 64) + s
    n = (n - m) / 26
  }
  return s
}

 

一、输出文件格式为txt、csv、doc、json:

1.点击链接或按钮:下载xxx.doc、xxx.csv

        <a href="javascript:;" id="download" @click="download()" download="download.doc">导出数据</a>
       <button @click="download()">导出数据</button>
          download () {// 遍历拼接
            var obj = document.getElementById(‘download‘);
            var str = "姓名,出生日期,地址\n";//标题
            for (var i = 0; i < this.tableData.length; i++) {
              var item = this.tableData[i];
              str += item.name + ‘,‘ + item.type + ‘,‘ + item.proj_id;
              str += "\n";
            }
            str = encodeURIComponent(str);
            obj.href = "data:text/csv;charset=utf-8,\ufeff" + str;
            obj.download = "download.doc";//文件名称+格式
          },
        }   // 下载json
    loadDoc (res, name) {
      const fileName = name
      let fileData = ‘‘
      res.forEach((val, index) => {
        let json = JSON.stringify(JSON.parse(val.fields), null, 4)
        json = json.replace(/\n/gi, \r\n)
        fileData += `${index + 1}.${val.cname}:\r\n\r\n${json}\r\n\r\n`
      })
      fileData = \uFEFF + fileData
      let blob = new Blob([fileData], {
        type: `text/plain;charset=UTF-8` // word文档为msword,pdf文档为pdf
      })
      let objectUrl = URL.createObjectURL(blob)
      let link = document.createElement(a)
      link.href = objectUrl
      link.setAttribute(download, fileName)
      document.body.appendChild(link)
      link.click()
    },
    exportDoc () {
      const fileName = 接口协议 + moment().format(YYYY-MM-DD,HH-mm-ss)
      let fileData = fileName + \n
      this.tableData.map((item, index) => {
        fileData += `${index + 1}.1.xxxx:\n  ${item.function}\n${index + 1}.2.xxxx:\n  ${item.address}\n${index + 1}\n`
      })
      let blob = new Blob([fileData], {
        type: `application/msword`
      })
      let objectUrl = URL.createObjectURL(blob)
      let link = document.createElement(a)
      link.href = objectUrl
      link.setAttribute(download, fileName)
      document.body.appendChild(link)
      link.click()
    },

参见 stackoverflow 中的两篇文章:使用Blob 和URL 来封装和转换

http://stackoverflow.com/questions/23962284/download-attribute-on-a-tag-doesnt-work-in-chrome
http://stackoverflow.com/questions/23816005/anchor-tag-download-attribute-not-working-bug-in-chrome-35-0-1916-114

      downloadLog(str){
        let data = \uFEFF + str
        let blob = new Blob([data], { type: text/csv,charset=UTF-8})
        let link = document.createElement(a)
        link.href = window.URL.createObjectURL(blob)
        link.download = 导出完整日志+_ + moment().format(YYYY-MM-DD HH:mm:ss)+.txt
        link.click()
      },

二、输出文件格式为xls、xlsx

 假设有2组table数据:

columns01:[‘类型‘,‘名称‘,‘描述‘],
table01: [
    { type: "string", name: "hell", desc: "你好" },
    { type: "number", name: "111", desc: "数字111" },
    { type: "string", name: "qq", desc: "QQ号" }
],
columns02:[‘姓名‘,‘年龄‘,‘性别‘],
table02: [
    { name: "z3", age: 16, sex: "男" },
    { name: "l4", age: 20, sex: "女" },
    { name: "w5", age: 24, sex: "男" },
    { name: "z6", age: 23, sex: "女" },
    { name: "ss", age: 10, sex: "不男不女" }
]

 导出excel插件

import moment from moment
import XLSX from xlsx
import _ from lodash
// 导出方法1
const exportExcel = (tableData, business) => {
  const columns = [标题1, 标题2]
  const data = []// 数据
  const workbook = outputXlsxFile(columns, data)
  let newWorkBook = XLSX.utils.book_new()
  const fileName = 导出命名 + moment().format(YYYY-MM-DD,HH-mm-ss) + .xlsx
  XLSX.utils.book_append_sheet(newWorkBook, workbook, 导出命名- + business || ‘‘)
  XLSX.writeFile(newWorkBook, fileName)
}
//转换方法2
const outputXlsxFile = (columns, data) => {
  let headObj = {} // 生成表头
  let indexObj = {} // 生成表内数据
  let renge = {}// 计算出范围A1:F4
  for (let i = 0; i < columns.length; i++) {
    let str = String.fromCharCode(65 + i) + 1
    if (i > 26) {
      str = String.fromCharCode(65) + String.fromCharCode(65 + i - 26) + 1
    }
    headObj[str] = { v: columns[i] }
  }
  const indexArr = []
  for (let e = 0; e < data.length; e++) {
    for (let j = 0; j < columns.length; j++) {
      let index = String.fromCharCode(65 + j) + (e + 2)
      indexArr.push(index)
    }
  }
  for (let i = 0; i < indexArr.length; i++) {
    indexObj[indexArr[i]] = { v: ‘‘ }
  }
  const excelArr = []
  for (let r = 0; r < data.length; r++) {
    let rec = data[r]
    for (let ii in rec) {
      excelArr.push(rec[ii])
    }
  }
  for (let ind = 0; ind < indexArr.length; ind++) {
    let j = 0
    for (let jj in indexObj) {
      if (indexArr[ind] === jj) {
        indexObj[jj].v = excelArr[j]
        break
      }
      j++
    }
  }
  let refS = A1
  let refExcel = String.fromCharCode(65 + columns.length - 1) + (data.length + 1)
  renge = { !ref: refS + : + refExcel }// 范围
  return _.assign(headObj, indexObj, renge)
}
//*********************************************
// 导出表格数据:
const exportExcelTable = (tableData, tableColumn, xlsName) => {
  const column = tableColumn || [] // 标题
  const data = tableData || []// 数据
  const workbook = outputXlsxFile(column, data)
  let newWorkBook = XLSX.utils.book_new()
  const fileName = xlsName + _ + moment().format(YYYY-MM-DD HH:mm:ss) + .xlsx
  XLSX.utils.book_append_sheet(newWorkBook, workbook, xlsName)
  XLSX.writeFile(newWorkBook, fileName)
}
//**********************************************
// 直接输出tabel:定义id或利用ref获取
const exportTableToExcel = (id, filename, xlsName) => {
  /* the first way */
  // const table = document.getElementById(id)
  // const wb = XLSX.utils.table_to_book(table)
  // XLSX.writeFile(wb, filename)

  /* the second way */
  const table = document.getElementById(id)
  const wb = XLSX.utils.book_new()
  const ws = XLSX.utils.table_to_sheet(table)
  XLSX.utils.book_append_sheet(wb, ws, xlsName)
  XLSX.writeFile(wb, filename)
}

图片导出+分页

    exportExcelAll () { // 导出多张图
      const keys = Object.keys(this.radarResult)
      const dataList = []
      const qrCodes = {}
      keys.forEach((item, index) => {
        qrCodes[index] = this.getBase64Code(index)
        dataList.push({
          name: item,
          data: this.radarResult[item].data
        })
      })
      const fileName = xxxx + moment().format(YYYY-MM-DD_HH-mm-ss)// 文件名称
      export_txt_to_zip(qrCodes, dataList,fileName)
    },
    getBase64Code (index) {// 去除echart图片前缀
      let arr = []
      const base64data01 = this.$refs[`radar_echarts_data64_0`][index].getDataURL() || ‘‘
      const base64data02 = this.$refs[`radar_echarts_data64_1`][index].getDataURL() || ‘‘
      if (base64data01 && base64data02) {
        const img01 = base64data01.replace(/data:image\/.*;base64,/, ‘‘)
        const img02 = base64data02.replace(/data:image\/.*;base64,/, ‘‘)
        arr.push([img01, img02])
      }
      return arr
    },

【自定义exel文件内容】

/* eslint-disable */
require(file-saver);

import JSZip from jszip
import {
    Content_Types,
    relsData,
    appData,
    coreData,
    stylesData,
    workbookData,
    workbookXml,
    drawing1Data,
    theme1Data,
    sheet1Data,
} from ./xlsxStyles

export function export_txt_to_zip(imgData, chartData ,xlsxName) {
    // console.log(imgData,"图形");
    // console.log(chartData ,"数据");
  const zip = new JSZip();
  const zip_name = xlsxName || excel文档;

    // 第一层文件夹:
    const _rels = zip.folder("_rels");
    const docProps = zip.folder("docProps");//app.xml core.xml custom.xml
    const xl = zip.folder("xl"); // sharedStrings.xml styles.xml workbook.xml

  // 第二层文件夹:
    const xl_rels = xl.folder("_rels");
    const media = xl.folder("media"); //图片2*6=12
    const theme = xl.folder("theme");// theme1.xml
    const drawings = xl.folder("drawings"); // 【1个关系文件夹+数据文件6个】
    const worksheets = xl.folder("worksheets"); // 【1个关系文件夹+数据文件6个】

    // 第三层文件夹:
    const drawings_xl_rels = drawings.folder("_rels");
    const sheets_xl_rels = worksheets.folder("_rels");//可以不需要关系文档
    
    // 文件内容
    //【1】
    let Content_TypesDemo = Content_Types;

    //【2】
    _rels.file(`.rels`, relsData);
    //【3】
    let appDataDemo = appData
    appDataDemo += `
            <vt:i4>${chartData.length}</vt:i4>
            </vt:variant>
        </vt:vector>
        </HeadingPairs>
        <TitlesOfParts>
        <vt:vector size="${chartData.length}" baseType="lpstr">
    `;
    //【4】
    docProps.file(`core.xml`, coreData);
    //【5】
    // docProps.file(`custom.xml`, customData);
    //【6】
    let workbookXmlDemo = workbookXml
    //【7】
    let workbookDataDemo = workbookData
    //【8】样式
    xl.file(`styles.xml`, stylesData);
    //【9】主题
    theme.file(`theme1.xml`, theme1Data);
    //【10】数据
    let sharedStringsData = `` //共享数据
    //参数
    let num = 0 // 图片文件标记
    let rowNum = 0;//共享数据标记
    chartData.forEach((item,index)=>{
        let sheetData = sheet1Data //模板
        // 计算参数
        const maxLenArr = item.data.map(v=>v.length)
        const maxLen = Math.max(...maxLenArr)
        const dataLen = item.data.length
        const dimension = String.fromCharCode(65 + maxLen-1) + String(dataLen)
        // 遍历数据
        sheetData += `
            <dimension ref="A1:${dimension}" />
            <sheetViews>
                <sheetView ${index===0?tabSelected="1":‘‘} workbookViewId="0" />
            </sheetViews>
            <sheetFormatPr defaultColWidth="9" defaultRowHeight="14.25" x14ac:dyDescent="0.2" />
            <sheetData>`;
        let row = 0;
        item.data.forEach((val)=>{//字符串区分:纯数字与其它
            row++
            sheetData += `<row r="${row}" spans="1:${maxLen}" x14ac:dyDescent="0.2">`;//第1行开始,每行条数
            val.forEach((v,i)=>{//.replace(/-/g, ‘‘)
                const newVal = String(v).replace(/</g, ().replace(/>/g, )) //去除横杆(减号)+转换尖括号(大于小于号)
                const abc = String.fromCharCode(65+i)+String(row)
                var reg = /^[0-9]+.?[0-9]*$/
                if (reg.test(v)) {
                    sheetData += `<c r="${abc}" s="1"><v>${+v}</v></c>`;//数字
                }else{ // 非纯数字:需要单独存储
                    sheetData += `<c r="${abc}" s="2" t="s"><v>${rowNum}</v></c>`;
                    sharedStringsData += `<si><t>${newVal}</t></si>`;
                    rowNum++
                }
            })
            sheetData += `</row>`;
        })
        sheetData += `</sheetData>
        <phoneticPr fontId="1" type="noConversion" />
        <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3" />
        <drawing r:id="rId1" />
        </worksheet>`
        worksheets.file(`sheet${index+1}.xml`, sheetData);//1.
        //2.动态模板
        let sheet_xml_rels = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
            <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing" Target="../drawings/drawing${index+1}.xml" />
        </Relationships>`
        sheets_xl_rels.file(`sheet${index+1}.xml.rels`, sheet_xml_rels);
        //3.固定模板
        let drawingData = drawing1Data
        drawings.file(`drawing${index+1}.xml`, drawingData);
        //4.动态模板
        let drawing_xml_rels = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
            <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/image${2*index+2}.png" />
            <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/image${2*index+1}.png" />
        </Relationships>
        `
        drawings_xl_rels.file(`drawing${index+1}.xml.rels`, drawing_xml_rels);
        //图片
        imgData[index][0].forEach((v,i)=>{
            num++
            media.file(`image${num}.png`, v, {base64: true});
        })
        //sheet1-6 :chartData
        appDataDemo +=`<vt:lpstr>${item.name}</vt:lpstr>`;
        workbookDataDemo +=`<sheet name="${item.name}" sheetId="${index+1}" r:id="rId${index+1}" />`;
        //1-10
        Content_TypesDemo += `
            <Override PartName="/xl/worksheets/sheet${index+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" />
            <Override PartName="/xl/drawings/drawing${index+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.drawing+xml" />
        `;
        //1-10
        workbookXmlDemo +=`<Relationship Id="rId${index+1}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${index+1}.xml" />`
    })
    appDataDemo +=`        </vt:vector>
    </TitlesOfParts>
    <Company></Company>
    <LinksUpToDate>false</LinksUpToDate>
    <SharedDoc>false</SharedDoc>
    <HyperlinksChanged>false</HyperlinksChanged>
    <AppVersion>16.0300</AppVersion>
</Properties>
    `;
    docProps.file(`app.xml`, appDataDemo);//sheet1-6
    workbookDataDemo +=`    </sheets>
    <calcPr calcId="191029" />
    <extLst>
        <ext uri="{140A7094-0E35-4892-8432-C4D2E57EDEB5}" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main">
            <x15:workbookPr chartTrackingRefBase="1" />
        </ext>
        <ext uri="{B58B0392-4F1F-4190-BB64-5DF3571DCE5F}" xmlns:xcalcf="http://schemas.microsoft.com/office/spreadsheetml/2018/calcfeatures">
            <xcalcf:calcFeatures>
                <xcalcf:feature name="microsoft.com:RD" />
                <xcalcf:feature name="microsoft.com:FV" />
            </xcalcf:calcFeatures>
        </ext>
    </extLst>
</workbook>
    `;
    xl.file(`workbook.xml`, workbookDataDemo);//sheet1-6
    //1-10
    Content_TypesDemo += `</Types>`;
    zip.file(`[Content_Types].xml`, Content_TypesDemo);
    //1-10
    workbookXmlDemo +=`</Relationships>`
    xl_rels.file(`workbook.xml.rels`, workbookXmlDemo);
    //共享数据
    let sharedStrings = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="${rowNum}" uniqueCount="${rowNum}">
    `;
    sharedStrings += sharedStringsData;
    sharedStrings +=`</sst>`;
    xl.file(`sharedStrings.xml`, sharedStrings);
  // 导出文件
  zip.generateAsync({type:"blob"}).then((blob) => {
    saveAs(blob, `${zip_name}.xlsx`)
  }, (err) => {
    // alert(‘导出失败‘)
  })
}

【模板样式】

const Content_Types = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
    <Default Extension="png" ContentType="image/png" />
    <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
    <Default Extension="xml" ContentType="application/xml" />
    <Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" />
    <Override PartName="/xl/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml" />
    <Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" />
    <Override PartName="/xl/sharedStrings.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml" />
    <Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml" />
    <Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" />
`;
const relsData = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
    <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"
     Target="docProps/app.xml" />
    <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
     Target="docProps/core.xml" />
    <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
     Target="xl/workbook.xml" />
</Relationships>
`;//2
const appData = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
    <Application>Microsoft Excel</Application>
    <DocSecurity>0</DocSecurity>
    <ScaleCrop>false</ScaleCrop>
    <HeadingPairs>
        <vt:vector size="2" baseType="variant">
            <vt:variant>
                <vt:lpstr>工作表</vt:lpstr>
            </vt:variant>
            <vt:variant>
`;
const coreData = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <dc:creator>zhangsan</dc:creator>
    <cp:lastModifiedBy>
zhangsan
</cp:lastModifiedBy> <dcterms:created xsi:type="dcterms:W3CDTF">2019-10-24T06:37:04Z</dcterms:created> <dcterms:modified xsi:type="dcterms:W3CDTF">2019-10-24T06:37:58Z</dcterms:modified> </cp:coreProperties> `;//4 const stylesData = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac x16r2 xr" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:x16r2="http://schemas.microsoft.com/office/spreadsheetml/2015/02/main" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision"> <fonts count="2" x14ac:knownFonts="1"> <font> <sz val="11" /> <color theme="1" /> <name val="等线" /> <family val="2" /> <charset val="134" /> <scheme val="minor" /> </font> <font> <sz val="9" /> <name val="等线" /> <family val="2" /> <charset val="134" /> <scheme val="minor" /> </font> </fonts> <fills count="2"> <fill> <patternFill patternType="none" /> </fill> <fill> <patternFill patternType="gray125" /> </fill> </fills> <borders count="2"> <border> <left /> <right /> <top /> <bottom /> <diagonal /> </border> <border> <left style="thin"> <color auto="1" /> </left> <right style="thin"> <color auto="1" /> </right> <top style="thin"> <color auto="1" /> </top> <bottom style="thin"> <color auto="1" /> </bottom> <diagonal /> </border> </borders> <cellStyleXfs count="1"> <xf numFmtId="0" fontId="0" fillId="0" borderId="0"> <alignment vertical="center" /> </xf> </cellStyleXfs> <cellXfs count="3"> <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"> <alignment vertical="center" /> </xf> <xf numFmtId="0" fontId="0" fillId="0" borderId="1" xfId="0" applyBorder="1"> <alignment vertical="center" /> </xf> <xf numFmtId="0" fontId="0" fillId="0" borderId="1" xfId="0" applyFill="1" applyBorder="1" applyAlignment="1"> <alignment vertical="center" /> </xf> </cellXfs> <cellStyles count="1"> <cellStyle name="常规" xfId="0" builtinId="0" /> </cellStyles> <dxfs count="0" /> <tableStyles count="0" defaultTableStyle="TableStyleMedium2" defaultPivotStyle="PivotStyleLight16" /> <extLst> <ext uri="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"> <x14:slicerStyles defaultSlicerStyle="SlicerStyleLight1" /> </ext> <ext uri="{9260A510-F301-46a8-8635-F512D64BE5F5}" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"> <x15:timelineStyles defaultTimelineStyle="TimeSlicerStyleLight1" /> </ext> </extLst> </styleSheet> `;//8 const workbookData = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x15 xr xr6 xr10 xr2" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr6="http://schemas.microsoft.com/office/spreadsheetml/2016/revision6" xmlns:xr10="http://schemas.microsoft.com/office/spreadsheetml/2016/revision10" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2"> <fileVersion appName="xl" lastEdited="7" lowestEdited="7" rupBuild="21328" /> <workbookPr defaultThemeVersion="166925" /> <mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"> <mc:Choice Requires="x15"> <x15ac:absPath url="F:\桌面文档\Desktop\" xmlns:x15ac="http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac" /> </mc:Choice> </mc:AlternateContent> <xr:revisionPtr revIDLastSave="0" documentId="8_{196D1D55-E4F8-4377-88D6-5858D66E76C9}" xr6:coauthVersionLast="41" xr6:coauthVersionMax="41" xr10:uidLastSave="{00000000-0000-0000-0000-000000000000}" /> <bookViews> <workbookView xWindow="3120" yWindow="3120" windowWidth="21600" windowHeight="11385" xr2:uid="{34091552-747D-432E-B85E-CE2889A72913}" /> </bookViews> <sheets> ` const workbookXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> <Relationship Id="rId11" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml" /> <Relationship Id="rId13" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.xml" /> <Relationship Id="rId12" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml" /> `; const drawing1Data = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xdr:wsDr xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"> <xdr:twoCellAnchor editAs="oneCell"> <xdr:from> <xdr:col>9</xdr:col> <xdr:colOff>0</xdr:colOff> <xdr:row>0</xdr:row> <xdr:rowOff>161925</xdr:rowOff> </xdr:from> <xdr:to> <xdr:col>15</xdr:col> <xdr:colOff>542925</xdr:colOff> <xdr:row>16</xdr:row> <xdr:rowOff>38100</xdr:rowOff> </xdr:to> <xdr:pic> <xdr:nvPicPr> <xdr:cNvPr id="2" name="图片 1" descr="图1"> <a:extLst> <a:ext uri="{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"> <a16:creationId xmlns:a16="http://schemas.microsoft.com/office/drawing/2014/main" id="{DBC454C4-E53E-44C6-8084-8CC906FB85C6}" /> </a:ext> <a:ext uri="{00000000-0001-0000-0000-000000000000}"> <a16:creationId xmlns:a16="http://schemas.microsoft.com/office/drawing/2014/main" xmlns="" id="{00000000-0000-0000-0000-000000000000}" /> </a:ext> </a:extLst> </xdr:cNvPr> <xdr:cNvPicPr> <a:picLocks noChangeAspect="1" /> </xdr:cNvPicPr> </xdr:nvPicPr> <xdr:blipFill> <a:blip xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:embed="rId1" /> <a:stretch> <a:fillRect /> </a:stretch> </xdr:blipFill> <xdr:spPr> <a:xfrm> <a:off x="6172200" y="161925" /> <a:ext cx="4657725" cy="2771775" /> </a:xfrm> <a:prstGeom prst="rect"> <a:avLst /> </a:prstGeom> </xdr:spPr> </xdr:pic> <xdr:clientData /> </xdr:twoCellAnchor> <xdr:twoCellAnchor editAs="oneCell"> <xdr:from> <xdr:col>9</xdr:col> <xdr:colOff>9525</xdr:colOff> <xdr:row>18</xdr:row> <xdr:rowOff>9525</xdr:rowOff> </xdr:from> <xdr:to> <xdr:col>15</xdr:col> <xdr:colOff>542925</xdr:colOff> <xdr:row>33</xdr:row> <xdr:rowOff>114300</xdr:rowOff> </xdr:to> <xdr:pic> <xdr:nvPicPr> <xdr:cNvPr id="3" name="图片 2" descr="图2"> <a:extLst> <a:ext uri="{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"> <a16:creationId xmlns:a16="http://schemas.microsoft.com/office/drawing/2014/main" id="{FE55B7B0-AAFF-4F5F-BC91-1BACB192D31C}" /> </a:ext> <a:ext uri="{00000000-0001-0000-0000-000000000000}"> <a16:creationId xmlns:a16="http://schemas.microsoft.com/office/drawing/2014/main" xmlns="" id="{00000000-0001-0000-0000-000000000000}" /> </a:ext> </a:extLst> </xdr:cNvPr> <xdr:cNvPicPr> <a:picLocks noChangeAspect="1" /> </xdr:cNvPicPr> </xdr:nvPicPr> <xdr:blipFill> <a:blip xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:embed="rId2" /> <a:stretch> <a:fillRect /> </a:stretch> </xdr:blipFill> <xdr:spPr> <a:xfrm> <a:off x="6181725" y="3267075" /> <a:ext cx="4648200" cy="2819400" /> </a:xfrm> <a:prstGeom prst="rect"> <a:avLst /> </a:prstGeom> </xdr:spPr> </xdr:pic> <xdr:clientData /> </xdr:twoCellAnchor> </xdr:wsDr> `; const theme1Data = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office 主题??"> <a:themeElements> <a:clrScheme name="Office"> <a:dk1> <a:sysClr val="windowText" lastClr="000000" /> </a:dk1> <a:lt1> <a:sysClr val="window" lastClr="FFFFFF" /> </a:lt1> <a:dk2> <a:srgbClr val="44546A" /> </a:dk2> <a:lt2> <a:srgbClr val="E7E6E6" /> </a:lt2> <a:accent1> <a:srgbClr val="4472C4" /> </a:accent1> <a:accent2> <a:srgbClr val="ED7D31" /> </a:accent2> <a:accent3> <a:srgbClr val="A5A5A5" /> </a:accent3> <a:accent4> <a:srgbClr val="FFC000" /> </a:accent4> <a:accent5> <a:srgbClr val="5B9BD5" /> </a:accent5> <a:accent6> <a:srgbClr val="70AD47" /> </a:accent6> <a:hlink> <a:srgbClr val="0563C1" /> </a:hlink> <a:folHlink> <a:srgbClr val="954F72" /> </a:folHlink> </a:clrScheme> <a:fontScheme name="Office"> <a:majorFont> <a:latin typeface="Calibri Light" panose="020F0302020204030204" /> <a:ea typeface="" /> <a:cs typeface="" /> <a:font script="Jpan" typeface="游ゴシック Light" /> <a:font script="Hang" typeface="?? ??" /> <a:font script="Hans" typeface="等线 Light" /> <a:font script="Hant" typeface="新細明體" /> <a:font script="Arab" typeface="Times New Roman" /> <a:font script="Hebr" typeface="Times New Roman" /> <a:font script="Thai" typeface="Tahoma" /> <a:font script="Ethi" typeface="Nyala" /> <a:font script="Beng" typeface="Vrinda" /> <a:font script="Gujr" typeface="Shruti" /> <a:font script="Khmr" typeface="MoolBoran" /> <a:font script="Knda" typeface="Tunga" /> <a:font script="Guru" typeface="Raavi" /> <a:font script="Cans" typeface="Euphemia" /> <a:font script="Cher" typeface="Plantagenet Cherokee" /> <a:font script="Yiii" typeface="Microsoft Yi Baiti" /> <a:font script="Tibt" typeface="Microsoft Himalaya" /> <a:font script="Thaa" typeface="MV Boli" /> <a:font script="Deva" typeface="Mangal" /> <a:font script="Telu" typeface="Gautami" /> <a:font script="Taml" typeface="Latha" /> <a:font script="Syrc" typeface="Estrangelo Edessa" /> <a:font script="Orya" typeface="Kalinga" /> <a:font script="Mlym" typeface="Kartika" /> <a:font script="Laoo" typeface="DokChampa" /> <a:font script="Sinh" typeface="Iskoola Pota" /> <a:font script="Mong" typeface="Mongolian Baiti" /> <a:font script="Viet" typeface="Times New Roman" /> <a:font script="Uigh" typeface="Microsoft Uighur" /> <a:font script="Geor" typeface="Sylfaen" /> <a:font script="Armn" typeface="Arial" /> <a:font script="Bugi" typeface="Leelawadee UI" /> <a:font script="Bopo" typeface="Microsoft JhengHei" /> <a:font script="Java" typeface="Javanese Text" /> <a:font script="Lisu" typeface="Segoe UI" /> <a:font script="Mymr" typeface="Myanmar Text" /> <a:font script="Nkoo" typeface="Ebrima" /> <a:font script="Olck" typeface="Nirmala UI" /> <a:font script="Osma" typeface="Ebrima" /> <a:font script="Phag" typeface="Phagspa" /> <a:font script="Syrn" typeface="Estrangelo Edessa" /> <a:font script="Syrj" typeface="Estrangelo Edessa" /> <a:font script="Syre" typeface="Estrangelo Edessa" /> <a:font script="Sora" typeface="Nirmala UI" /> <a:font script="Tale" typeface="Microsoft Tai Le" /> <a:font script="Talu" typeface="Microsoft New Tai Lue" /> <a:font script="Tfng" typeface="Ebrima" /> </a:majorFont> <a:minorFont> <a:latin typeface="Calibri" panose="020F0502020204030204" /> <a:ea typeface="" /> <a:cs typeface="" /> <a:font script="Jpan" typeface="游ゴシック" /> <a:font script="Hang" typeface="?? ??" /> <a:font script="Hans" typeface="等线" /> <a:font script="Hant" typeface="新細明體" /> <a:font script="Arab" typeface="Arial" /> <a:font script="Hebr" typeface="Arial" /> <a:font script="Thai" typeface="Tahoma" /> <a:font script="Ethi" typeface="Nyala" /> <a:font script="Beng" typeface="Vrinda" /> <a:font script="Gujr" typeface="Shruti" /> <a:font script="Khmr" typeface="DaunPenh" /> <a:font script="Knda" typeface="Tunga" /> <a:font script="Guru" typeface="Raavi" /> <a:font script="Cans" typeface="Euphemia" /> <a:font script="Cher" typeface="Plantagenet Cherokee" /> <a:font script="Yiii" typeface="Microsoft Yi Baiti" /> <a:font script="Tibt" typeface="Microsoft Himalaya" /> <a:font script="Thaa" typeface="MV Boli" /> <a:font script="Deva" typeface="Mangal" /> <a:font script="Telu" typeface="Gautami" /> <a:font script="Taml" typeface="Latha" /> <a:font script="Syrc" typeface="Estrangelo Edessa" /> <a:font script="Orya" typeface="Kalinga" /> <a:font script="Mlym" typeface="Kartika" /> <a:font script="Laoo" typeface="DokChampa" /> <a:font script="Sinh" typeface="Iskoola Pota" /> <a:font script="Mong" typeface="Mongolian Baiti" /> <a:font script="Viet" typeface="Arial" /> <a:font script="Uigh" typeface="Microsoft Uighur" /> <a:font script="Geor" typeface="Sylfaen" /> <a:font script="Armn" typeface="Arial" /> <a:font script="Bugi" typeface="Leelawadee UI" /> <a:font script="Bopo" typeface="Microsoft JhengHei" /> <a:font script="Java" typeface="Javanese Text" /> <a:font script="Lisu" typeface="Segoe UI" /> <a:font script="Mymr" typeface="Myanmar Text" /> <a:font script="Nkoo" typeface="Ebrima" /> <a:font script="Olck" typeface="Nirmala UI" /> <a:font script="Osma" typeface="Ebrima" /> <a:font script="Phag" typeface="Phagspa" /> <a:font script="Syrn" typeface="Estrangelo Edessa" /> <a:font script="Syrj" typeface="Estrangelo Edessa" /> <a:font script="Syre" typeface="Estrangelo Edessa" /> <a:font script="Sora" typeface="Nirmala UI" /> <a:font script="Tale" typeface="Microsoft Tai Le" /> <a:font script="Talu" typeface="Microsoft New Tai Lue" /> <a:font script="Tfng" typeface="Ebrima" /> </a:minorFont> </a:fontScheme> <a:fmtScheme name="Office"> <a:fillStyleLst> <a:solidFill> <a:schemeClr val="phClr" /> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:lumMod val="110000" /> <a:satMod val="105000" /> <a:tint val="67000" /> </a:schemeClr> </a:gs> <a:gs pos="50000"> <a:schemeClr val="phClr"> <a:lumMod val="105000" /> <a:satMod val="103000" /> <a:tint val="73000" /> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:lumMod val="105000" /> <a:satMod val="109000" /> <a:tint val="81000" /> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="5400000" scaled="0" /> </a:gradFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:satMod val="103000" /> <a:lumMod val="102000" /> <a:tint val="94000" /> </a:schemeClr> </a:gs> <a:gs pos="50000"> <a:schemeClr val="phClr"> <a:satMod val="110000" /> <a:lumMod val="100000" /> <a:shade val="100000" /> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:lumMod val="99000" /> <a:satMod val="120000" /> <a:shade val="78000" /> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="5400000" scaled="0" /> </a:gradFill> </a:fillStyleLst> <a:lnStyleLst> <a:ln w="6350" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr" /> </a:solidFill> <a:prstDash val="solid" /> <a:miter lim="800000" /> </a:ln> <a:ln w="12700" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr" /> </a:solidFill> <a:prstDash val="solid" /> <a:miter lim="800000" /> </a:ln> <a:ln w="19050" cap="flat" cmpd="sng" algn="ctr"> <a:solidFill> <a:schemeClr val="phClr" /> </a:solidFill> <a:prstDash val="solid" /> <a:miter lim="800000" /> </a:ln> </a:lnStyleLst> <a:effectStyleLst> <a:effectStyle> <a:effectLst /> </a:effectStyle> <a:effectStyle> <a:effectLst /> </a:effectStyle> <a:effectStyle> <a:effectLst> <a:outerShdw blurRad="57150" dist="19050" dir="5400000" algn="ctr" rotWithShape="0"> <a:srgbClr val="000000"> <a:alpha val="63000" /> </a:srgbClr> </a:outerShdw> </a:effectLst> </a:effectStyle> </a:effectStyleLst> <a:bgFillStyleLst> <a:solidFill> <a:schemeClr val="phClr" /> </a:solidFill> <a:solidFill> <a:schemeClr val="phClr"> <a:tint val="95000" /> <a:satMod val="170000" /> </a:schemeClr> </a:solidFill> <a:gradFill rotWithShape="1"> <a:gsLst> <a:gs pos="0"> <a:schemeClr val="phClr"> <a:tint val="93000" /> <a:satMod val="150000" /> <a:shade val="98000" /> <a:lumMod val="102000" /> </a:schemeClr> </a:gs> <a:gs pos="50000"> <a:schemeClr val="phClr"> <a:tint val="98000" /> <a:satMod val="130000" /> <a:shade val="90000" /> <a:lumMod val="103000" /> </a:schemeClr> </a:gs> <a:gs pos="100000"> <a:schemeClr val="phClr"> <a:shade val="63000" /> <a:satMod val="120000" /> </a:schemeClr> </a:gs> </a:gsLst> <a:lin ang="5400000" scaled="0" /> </a:gradFill> </a:bgFillStyleLst> </a:fmtScheme> </a:themeElements> <a:objectDefaults /> <a:extraClrSchemeLst /> <a:extLst> <a:ext uri="{05A4C25C-085E-4340-85A3-A5531E510DB2}"> <thm15:themeFamily xmlns:thm15="http://schemas.microsoft.com/office/thememl/2012/main" name="Office Theme" id="{62F939B6-93AF-4DB8-9C6B-D6C7DFDC589F}" vid="{4A3C46E8-61CC-4603-A589-7422A47A8E4A}" /> </a:ext> </a:extLst> </a:theme> `; const sheet1Data = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac xr xr2 xr3" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2" xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3" xr:uid="{1BFF9BC4-F55F-4B5B-9B59-49E4BD0BE67B}"> `; export { Content_Types, relsData, appData, coreData, stylesData, workbookData, workbookXml, drawing1Data, theme1Data, sheet1Data, }

注意:模板设置需要统一,否则office365会报错,比如导出多个分栏时!!!

导出文件——实现方法汇总

标签:mem   net   nload   business   动态   enc   nbsp   否则   import   

原文地址:https://www.cnblogs.com/wheatCatcher/p/11541096.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!