一、准备工作:

2个js库,另外把样式文件抽离出来

  1. require('file-saver');
  2. import JSZip from 'jszip'
  3. import {stylesData,theme1Data} from './xlsxStyles'

转换成OOXML文档:

新建“工作簿1.xlsx”,修改后缀.zip,得到如下目录结构:

内容、属性文档目录:content_Types

  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
  3. <Default Extension="png" ContentType="image/png" />
  4. <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
  5. <Default Extension="xml" ContentType="application/xml" />
  6. <Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" />
  7. <Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml" />
  8. <Override PartName="/xl/sharedStrings.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml" /> //字符串存储共享文件
  9. <Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" />
  10. <Override PartName="/xl/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml" />
  11. <Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" />
  12.  
  13. <Override PartName="/docProps/custom.xml" ContentType="application/vnd.openxmlformats-officedocument.custom-properties+xml" /> //自定义属性文档:如有样式设置
  14.  
  15. <Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" /> //遍历:纯数字数据文档或内嵌的字符串
  16. <Override PartName="/xl/worksheets/sheet2.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" />
  17. <Override PartName="/xl/worksheets/sheet3.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" />
  18. <Override PartName="/xl/worksheets/sheet4.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" />
  19. <Override PartName="/xl/worksheets/sheet5.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" />
  20. <Override PartName="/xl/worksheets/sheet6.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" />
  21.  
  22. <Override PartName="/xl/drawings/drawing1.xml" ContentType="application/vnd.openxmlformats-officedocument.drawing+xml" /> //遍历:数据关联文档,如插入图片、表格
  23. <Override PartName="/xl/drawings/drawing2.xml" ContentType="application/vnd.openxmlformats-officedocument.drawing+xml" />
  24. <Override PartName="/xl/drawings/drawing3.xml" ContentType="application/vnd.openxmlformats-officedocument.drawing+xml" />
  25. <Override PartName="/xl/drawings/drawing4.xml" ContentType="application/vnd.openxmlformats-officedocument.drawing+xml" />
  26. <Override PartName="/xl/drawings/drawing5.xml" ContentType="application/vnd.openxmlformats-officedocument.drawing+xml" />
  27. <Override PartName="/xl/drawings/drawing6.xml" ContentType="application/vnd.openxmlformats-officedocument.drawing+xml" />
  28. </Types>

1.1关联文件:

  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
  3. <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml" />
  4. <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml" />
  5. <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml" />
  6. </Relationships>

复杂一点的:多个自定义custom.xml文件

  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
  3. <Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties" Target="docProps/custom.xml" />
      ...
  4. </Relationships>

1.2.文档属性:

 或

多一个自定义xml文档:目测fmtid是随机生成的UUID

  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
  3. <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="" name="KSOProductBuildVer">
  4. <vt:lpwstr>-11.1.0.8976</vt:lpwstr>
  5. </property>
  6. </Properties>

其他2个文件:

app.xml:分页sheet文档,如果是wps生成的信息没有那么全

  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
  3. <Application>Microsoft Excel</Application>
  4. <DocSecurity>0</DocSecurity>
  5. <ScaleCrop>false</ScaleCrop>
  6. <HeadingPairs>
  7. <vt:vector size="2" baseType="variant">
  8. <vt:variant>
  9. <vt:lpstr>工作表</vt:lpstr>
  10. </vt:variant>
  11. <vt:variant>
  12. <vt:i4>6</vt:i4> //合计总数:6
  13. </vt:variant>
  14. </vt:vector>
  15. </HeadingPairs>
  16. <TitlesOfParts>
  17. <vt:vector size="6" baseType="lpstr"> //合计总数+遍历1-6
  18. <vt:lpstr>Sheet1</vt:lpstr>
  19. <vt:lpstr>Sheet2</vt:lpstr>
  20. <vt:lpstr>Sheet3</vt:lpstr>
  21. <vt:lpstr>Sheet4</vt:lpstr>
  22. <vt:lpstr>Sheet5</vt:lpstr>
  23. <vt:lpstr>Sheet6</vt:lpstr>
  24. </vt:vector>
  25. </TitlesOfParts>
  26. <Company></Company>
  27. <LinksUpToDate>false</LinksUpToDate>
  28. <SharedDoc>false</SharedDoc>
  29. <HyperlinksChanged>false</HyperlinksChanged>
  30. <AppVersion>16.0300</AppVersion>
  31. </Properties>

固定格式的core.xml文档信息:如创建人、创建时间

  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/"
  3. xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  4. <dc:creator>zhangsan</dc:creator>
  5. <cp:lastModifiedBy>zhangsan</cp:lastModifiedBy>
  6. <dcterms:created xsi:type="dcterms:W3CDTF">2019-10-21T12:16:00Z</dcterms:created>
  7. <dcterms:modified xsi:type="dcterms:W3CDTF">2019-10-21T12:16:16Z</dcterms:modified>
  8. </cp:coreProperties>

二、核心文件XL:

内容不为空多出一个字符串共享文档:

  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="841" uniqueCount="217">
  3. <si>
  4. <t>列1</t>
  5. </si>
  6. </sst>

如果是数据不为空,会多出1个drawings文档;

 如果有图片,会多出一个media文档;

 如果插入表格,会多出一个tables文档。

图形信息使用base64格式存储

  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <table xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" id="1" name="表1" displayName="表1" ref="A1:U25"
  3. totalsRowShown="0">
  4. <tableColumns count="21">
  5. <tableColumn id="1" name="列1" dataDxfId="0" />
  6. <tableColumn id="2" name="列2" dataDxfId="1" />
  7. <tableColumn id="3" name="列3" dataDxfId="2" />
  8. </tableColumns>
  9. <tableStyleInfo name="TableStyleMedium2" showFirstColumn="0" showLastColumn="0" showRowStripes="1" showColumnStripes="0" />
  10. </table>

其他:主题文件theme1.xml和外部样式文件styles.xml,数据可以抽离出来单独存放

三、数据输出:存储格式需要区分,并分开存储

  1. /* eslint-disable */
  2. require('file-saver');
  3.  
  4. import JSZip from 'jszip'
  5. import {stylesData,theme1Data} from './xlsxStyles'
  6.  
  7. export function export_txt_to_zip(imgData, chartData ,xlsxName) {
  8. // console.log(imgData,"图形");
  9. // console.log(chartData ,"数据");
  10. const chartDataLen = chartData.length || 1
  11. const zip = new JSZip();
  12. const zip_name = xlsxName || 'excel文档';
  13.  
  14. // 第一层文件夹:
  15. const _rels = zip.folder("_rels");
  16. const docProps = zip.folder("docProps");//app.xml core.xml custom.xml
  17. const xl = zip.folder("xl"); // sharedStrings.xml styles.xml workbook.xml
  18.  
  19. // 第二层文件夹:
  20. const xl_rels = xl.folder("_rels");
  21. const media = xl.folder("media"); //图片2*6=12
  22. const theme = xl.folder("theme");// theme1.xml
  23. const drawings = xl.folder("drawings"); // 【1个关系文件夹+数据文件6个】
  24. const worksheets = xl.folder("worksheets"); // 【1个关系文件夹+数据文件6个】
  25.  
  26. // 第三层文件夹:
  27. const drawings_xl_rels = drawings.folder("_rels");
  28. const sheets_xl_rels = worksheets.folder("_rels");//可以不需要关系文档
  29.  
  30. // 文件内容
  31. //【1】
  32. let xmlData =`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  33. <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
  34.  
  35. <Default Extension="png" ContentType="image/png" />
  36. <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
  37. <Default Extension="xml" ContentType="application/xml" />
  38.  
  39. <Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" />
  40. <Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml" />
  41. <Override PartName="/xl/sharedStrings.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml" />
  42.  
  43. <Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" />
  44. <Override PartName="/xl/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml" />
  45. <Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" />
  46. `;
  47. //【2】
  48. const relsData = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  49. <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
  50. <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml" />
  51. <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml" />
  52. <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml" />
  53. </Relationships>
  54. `;
  55. //【3】
  56. let appData = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  57. <Properties
  58. xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"
  59. xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
  60. <Application>表格</Application>
  61. <HeadingPairs>
  62. <vt:vector size="2" baseType="constiant">
  63. <vt:constiant>
  64. <vt:lpstr>工作表</vt:lpstr>
  65. </vt:constiant>
  66. <vt:constiant>
  67. <vt:i4>${chartDataLen}</vt:i4>
  68. </vt:constiant>
  69. </vt:vector>
  70. </HeadingPairs>
  71. <TitlesOfParts>
  72. <vt:vector size="${chartDataLen}" baseType="lpstr">
  73. `;
  74. //【4】
  75. let coreData = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  76. <cp:coreProperties
  77. xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
  78. xmlns:dc="http://purl.org/dc/elements/1.1/"
  79. xmlns:dcterms="http://purl.org/dc/terms/"
  80. xmlns:dcmitype="http://purl.org/dc/dcmitype/"
  81. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  82. xmlns:dc="http://purl.org/dc/elements/1.1/"
  83. xmlns:dcterms="http://purl.org/dc/terms/"
  84. xmlns:dcmitype="http://purl.org/dc/dcmitype/"
  85. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  86. `;
  87. // const userName = JSON.parse(localStorage.getItem("usern")).enname || '创建人'
  88. let creatTime = new Date().getFullYear() + '-';
  89. creatTime += (new Date().getMonth() + 1) + '-';
  90. creatTime += new Date().getDate() + 'T';
  91. creatTime += new Date().getHours() + ':';
  92. creatTime += new Date().getMinutes() + ':';
  93. creatTime += new Date().getSeconds() + 'Z';
  94. coreData += ` <dc:creator></dc:creator>`; // 创建人
  95. coreData += ` <cp:lastModifiedBy></cp:lastModifiedBy>`; // 最后修改人
  96. coreData += ` <dcterms:created xsi:type="dcterms:W3CDTF">${creatTime}</dcterms:created>`; // 创建时间
  97. coreData += ` <dcterms:modified xsi:type="dcterms:W3CDTF">${creatTime}</dcterms:modified>`; // 调整时间
  98. coreData += ` </cp:coreProperties>`;
  99. //【5】
  100. // const customData = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  101. // <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
  102. // <property fmtid="{00000000-0001-0000-0${index}00-000000000000}" pid="2" name="KSOProductBuildVer">
  103. // <vt:lpwstr>2052-11.1.0.8976</vt:lpwstr>
  104. // </property>
  105. // </Properties>
  106. // `;
  107. //【6】:字符串存储。
  108. let rowNum = 0;
  109. let sharedStringsData = ``;
  110. //【7】
  111. let xl_relsData = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  112. <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
  113. <Relationship Id="rId${chartDataLen+3}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.xml" />
  114. <Relationship Id="rId${chartDataLen+2}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml" />
  115. <Relationship Id="rId${chartDataLen+1}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml" />
  116. `;
  117. //【8】
  118. let workbookData = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  119. <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
  120. 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"
  121. xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr6="http://schemas.microsoft.com/office/spreadsheetml/2016/revision6"
  122. xmlns:xr10="http://schemas.microsoft.com/office/spreadsheetml/2016/revision10" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2">
  123. <fileVersion appName="xl" lastEdited="${chartDataLen+2}" lowestEdited="${chartDataLen+2}" rupBuild="21328" />
  124. <workbookPr />
  125. <bookViews>
  126. <workbookView windowWidth="28245" windowHeight="13500" />
  127. </bookViews>
  128. <sheets>
  129. `;
  130. chartData.forEach((item,index)=>{
  131. //【1】
  132. xmlData+=`<Override PartName="/xl/drawings/drawing${index+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.drawing+xml" />`;
  133. xmlData+=`<Override PartName="/xl/worksheets/sheet${index+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" />`;
  134. //【3】
  135. appData +=`<vt:lpstr>${item.name}</vt:lpstr>`;
  136. //【7】
  137. xl_relsData +=`<Relationship Id="rId${index+1}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${index+1}.xml" />`;
  138. //【8】
  139. workbookData +=`<sheet name="${item.name}" sheetId="${index+1}" r:id="rId${index+1}" />`;
  140. //【9】
  141. let drawing_xml_rels = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">`;
  142. let num = index*2
  143. imgData[index][0].forEach((v,i)=>{
  144. //【9】
  145. num++
  146. drawing_xml_rels += `<Relationship Id="rId${i+1}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/image${num}.png" />`;
  147. // 【11】图片文件
  148. media.file(`image${num}.png`, v, {base64: true});
  149. })
  150. drawing_xml_rels += `</Relationships>`;
  151. drawings_xl_rels.file(`drawing${index+1}.xml.rels`, drawing_xml_rels);
  152. //【12】
  153. const sheet_xml_rels = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  154. <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
  155. <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing" Target="../drawings/drawing${index+1}.xml" />
  156. </Relationships>
  157. `;
  158. sheets_xl_rels.file(`sheet${index+1}.xml.rels`, sheet_xml_rels);
  159. const maxLenArr = item.data.map(v=>v.length)
  160. const maxLen = Math.max(...maxLenArr) //es6
  161. const dataLen = item.data.length +1 //第一行:+1
  162. const dimension = String.fromCharCode(64 + maxLen) + String(dataLen)
  163. //【13】数据:不允许使用特殊符号标记
  164. let drawingData = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  165. <xdr:wsDr xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
  166. <xdr:twoCellAnchor editAs="oneCell">
  167. <xdr:from>
  168. <xdr:col>9</xdr:col>
  169. <xdr:colOff>0</xdr:colOff>
  170. <xdr:row>0</xdr:row>
  171. <xdr:rowOff>161925</xdr:rowOff>
  172. </xdr:from>
  173. <xdr:to>
  174. <xdr:col>15</xdr:col>
  175. <xdr:colOff>542925</xdr:colOff>
  176. <xdr:row>16</xdr:row>
  177. <xdr:rowOff>38100</xdr:rowOff>
  178. </xdr:to>
  179. <xdr:pic>
  180. <xdr:nvPicPr>
  181. <xdr:cNvPr id="2" name="图片 1" descr="图1">
  182. <a:extLst>
  183. <a:ext uri="{00000000-0001-0000-0${index}00-000000000000}">
  184. <a16:creationId xmlns:a16="http://schemas.microsoft.com/office/drawing/2014/main" id="{00000000-0000-0000-0${index}00-000000000000}" />
  185. </a:ext>
  186. </a:extLst>
  187. </xdr:cNvPr>
  188. <xdr:cNvPicPr>
  189. <a:picLocks noChangeAspect="1" />
  190. </xdr:cNvPicPr>
  191. </xdr:nvPicPr>
  192. <xdr:blipFill>
  193. <a:blip xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:embed="rId1" />
  194. <a:stretch>
  195. <a:fillRect />
  196. </a:stretch>
  197. </xdr:blipFill>
  198. <xdr:spPr>
  199. <a:xfrm>
  200. <a:off x="6172200" y="161925" />
  201. <a:ext cx="4657725" cy="2771775" />
  202. </a:xfrm>
  203. <a:prstGeom prst="rect">
  204. <a:avLst />
  205. </a:prstGeom>
  206. </xdr:spPr>
  207. </xdr:pic>
  208. <xdr:clientData />
  209. </xdr:twoCellAnchor>
  210. <xdr:twoCellAnchor editAs="oneCell">
  211. <xdr:from>
  212. <xdr:col>9</xdr:col>
  213. <xdr:colOff>9525</xdr:colOff>
  214. <xdr:row>18</xdr:row>
  215. <xdr:rowOff>9525</xdr:rowOff>
  216. </xdr:from>
  217. <xdr:to>
  218. <xdr:col>15</xdr:col>
  219. <xdr:colOff>542925</xdr:colOff>
  220. <xdr:row>33</xdr:row>
  221. <xdr:rowOff>114300</xdr:rowOff>
  222. </xdr:to>
  223. <xdr:pic>
  224. <xdr:nvPicPr>
  225. <xdr:cNvPr id="3" name="图片 2" descr="图2">
  226. <a:extLst>
  227. <a:ext uri="{00000000-0001-0000-0${index}00-000000000000}">
  228. <a16:creationId xmlns:a16="http://schemas.microsoft.com/office/drawing/2014/main" id="{00000000-0001-0000-0${index}00-000000000000}" />
  229. </a:ext>
  230. </a:extLst>
  231. </xdr:cNvPr>
  232. <xdr:cNvPicPr>
  233. <a:picLocks noChangeAspect="1" />
  234. </xdr:cNvPicPr>
  235. </xdr:nvPicPr>
  236. <xdr:blipFill>
  237. <a:blip xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:embed="rId2" />
  238. <a:stretch>
  239. <a:fillRect />
  240. </a:stretch>
  241. </xdr:blipFill>
  242. <xdr:spPr>
  243. <a:xfrm>
  244. <a:off x="6181725" y="3267075" />
  245. <a:ext cx="4648200" cy="2819400" />
  246. </a:xfrm>
  247. <a:prstGeom prst="rect">
  248. <a:avLst />
  249. </a:prstGeom>
  250. </xdr:spPr>
  251. </xdr:pic>
  252. <xdr:clientData />
  253. </xdr:twoCellAnchor>
  254. </xdr:wsDr>
  255. `;
  256. let sheetData = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  257. <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
  258. 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"
  259. xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2"
  260. xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3" xr:uid="{00000000-0001-0000-0${index}00-000000000000}">
  261. <sheetPr />
  262. <dimension ref="A1:${dimension}" />
  263. <sheetViews>
  264. <sheetView ${index===0?'tabSelected="1"':''} workbookViewId="0">
  265. <selection activeCell="A1" sqref="A1" />
  266. </sheetView>
  267. </sheetViews>
  268. <sheetFormatPr defaultColWidth="9" defaultRowHeight="14.25" x14ac:dyDescent="0.2" />
  269. <sheetData>`;
  270. let row = 0;
  271. item.data.forEach((val)=>{//字符串区分:纯数字与其它
  272. row++
  273. sheetData += `<row r="${row}" spans="1:${maxLen}" x14ac:dyDescent="0.2">`;//第1行开始,每行条数
  274. val.forEach((v,i)=>{
  275. const newVal = String(v).replace(/-/g, '').replace(/</g, '(').replace(/>/g, ')') //去除横杆(减号)+转换尖括号(大于小于号)
  276. const abc = String.fromCharCode(65+i)+String(row)
  277. var reg = /^[0-9]+.?[0-9]*$/
  278. if (reg.test(v)) {
  279. sheetData += `<c r="${abc}" s="1"><v>${v}</v></c>`;
  280. }else{ // 非纯数字:需要单独存储
  281. sheetData += `<c r="${abc}" s="2" t="s"><v>${rowNum}</v></c>`;
  282. sharedStringsData += `<si><t>${newVal}</t></si>`;
  283. rowNum++
  284. }
  285. })
  286. sheetData += `</row>`;
  287. })
  288. sheetData += `</sheetData>
  289. <phoneticPr fontId="1" type="noConversion" />
  290. <pageMargins left="0.75" right="0.75" top="1" bottom="1" header="0.5" footer="0.5" />
  291. <drawing r:id="rId1" />
  292. </worksheet>`
  293. worksheets.file(`sheet${index+1}.xml`, sheetData);
  294. drawings.file(`drawing${index+1}.xml`, drawingData);
  295. });
  296. //【1】
  297. xmlData+=`</Types>`;
  298. zip.file(`[Content_Types].xml`, xmlData);
  299. //【2】
  300. _rels.file(`.rels`, relsData);
  301. //【3】
  302. appData+=`</vt:vector></TitlesOfParts></Properties>`;
  303. docProps.file(`app.xml`, appData);
  304. //【4】
  305. docProps.file(`core.xml`, coreData);
  306. //【5】
  307. // docProps.file(`custom.xml`, customData);
  308. //【6】共享字符串
  309. let sharedStrings = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  310. <sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="${rowNum}" uniqueCount="${rowNum}">
  311. `;
  312. sharedStrings += sharedStringsData;
  313. sharedStrings +=`</sst>`;
  314. xl.file(`sharedStrings.xml`, sharedStrings);
  315. //【7】
  316. xl_relsData += `</Relationships>`;
  317. xl_rels.file(`workbook.xml.rels`, xl_relsData);
  318. //【8】
  319. workbookData +=`</sheets><calcPr calcId="144525" /></workbook>`;
  320. xl.file(`workbook.xml`, workbookData);
  321. // 样式与主题
  322. xl.file(`styles.xml`, stylesData);
  323. theme.file(`theme1.xml`, theme1Data);
  324. // 导出文件
  325. zip.generateAsync({type:"blob"}).then((blob) => {
  326. saveAs(blob, `${zip_name}.xlsx`)
  327. }, (err) => {
  328. alert('导出失败')
  329. })
  330. }

样式和主题抽离:

  1. const stylesData =`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <styleSheet
  3. xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. mc:Ignorable="x14ac x16r2 xr"
  6. xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"
  7. xmlns:x16r2="http://schemas.microsoft.com/office/spreadsheetml/2015/02/main"
  8. xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision">
  9. <fonts count="2" x14ac:knownFonts="1">
  10. <font>
  11. <sz val="11" />
  12. <color theme="1" />
  13. <name val="等线" />
  14. <family val="2" />
  15. <charset val="134" />
  16. <scheme val="minor" />
  17. </font>
  18. <font>
  19. <sz val="9" />
  20. <name val="等线" />
  21. <family val="2" />
  22. <charset val="134" />
  23. <scheme val="minor" />
  24. </font>
  25. </fonts>
  26. <fills count="2">
  27. <fill>
  28. <patternFill patternType="none" />
  29. </fill>
  30. <fill>
  31. <patternFill patternType="gray125" />
  32. </fill>
  33. </fills>
  34. <borders count="2">
  35. <border>
  36. <left />
  37. <right />
  38. <top />
  39. <bottom />
  40. <diagonal />
  41. </border>
  42. <border>
  43. <left style="thin">
  44. <color auto="1" />
  45. </left>
  46. <right style="thin">
  47. <color auto="1" />
  48. </right>
  49. <top style="thin">
  50. <color auto="1" />
  51. </top>
  52. <bottom style="thin">
  53. <color auto="1" />
  54. </bottom>
  55. <diagonal />
  56. </border>
  57. </borders>
  58. <cellStyleXfs count="1">
  59. <xf numFmtId="0" fontId="0" fillId="0" borderId="0">
  60. <alignment vertical="center" />
  61. </xf>
  62. </cellStyleXfs>
  63. <cellXfs count="3">
  64. <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0">
  65. <alignment vertical="center" />
  66. </xf>
  67. <xf numFmtId="0" fontId="0" fillId="0" borderId="1" xfId="0" applyBorder="1">
  68. <alignment vertical="center" />
  69. </xf>
  70. <xf numFmtId="0" fontId="0" fillId="0" borderId="1" xfId="0" applyFill="1" applyBorder="1" applyAlignment="1">
  71. <alignment vertical="center" />
  72. </xf>
  73. </cellXfs>
  74. <cellStyles count="1">
  75. <cellStyle name="常规" xfId="0" builtinId="0" />
  76. </cellStyles>
  77. <dxfs count="0" />
  78. <tableStyles count="0" defaultTableStyle="TableStyleMedium2" defaultPivotStyle="PivotStyleLight16" />
  79. <extLst>
  80. <ext uri="{00000000-0000-0000-0000-000000000000}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main">
  81. <x14:slicerStyles defaultSlicerStyle="SlicerStyleLight1" />
  82. </ext>
  83. <ext uri="{00000000-0001-0000-0000-000000000000}" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main">
  84. <x15:timelineStyles defaultTimelineStyle="TimeSlicerStyleLight1" />
  85. </ext>
  86. </extLst>
  87. </styleSheet>
  88. `;
  89. const theme1Data = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  90. <a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office 主题​​">
  91. <a:themeElements>
  92. <a:clrScheme name="Office">
  93. <a:dk1>
  94. <a:sysClr val="windowText" lastClr="000000" />
  95. </a:dk1>
  96. <a:lt1>
  97. <a:sysClr val="window" lastClr="FFFFFF" />
  98. </a:lt1>
  99. <a:dk2>
  100. <a:srgbClr val="44546A" />
  101. </a:dk2>
  102. <a:lt2>
  103. <a:srgbClr val="E7E6E6" />
  104. </a:lt2>
  105. <a:accent1>
  106. <a:srgbClr val="4472C4" />
  107. </a:accent1>
  108. <a:accent2>
  109. <a:srgbClr val="ED7D31" />
  110. </a:accent2>
  111. <a:accent3>
  112. <a:srgbClr val="A5A5A5" />
  113. </a:accent3>
  114. <a:accent4>
  115. <a:srgbClr val="FFC000" />
  116. </a:accent4>
  117. <a:accent5>
  118. <a:srgbClr val="5B9BD5" />
  119. </a:accent5>
  120. <a:accent6>
  121. <a:srgbClr val="70AD47" />
  122. </a:accent6>
  123. <a:hlink>
  124. <a:srgbClr val="0563C1" />
  125. </a:hlink>
  126. <a:folHlink>
  127. <a:srgbClr val="954F72" />
  128. </a:folHlink>
  129. </a:clrScheme>
  130. <a:fontScheme name="Office">
  131. <a:majorFont>
  132. <a:latin typeface="Calibri Light" panose="020F0302020204030204" />
  133. <a:ea typeface="" />
  134. <a:cs typeface="" />
  135. <a:font script="Jpan" typeface="游ゴシック Light" />
  136. <a:font script="Hang" typeface="맑은 고딕" />
  137. <a:font script="Hans" typeface="等线 Light" />
  138. <a:font script="Hant" typeface="新細明體" />
  139. <a:font script="Arab" typeface="Times New Roman" />
  140. <a:font script="Hebr" typeface="Times New Roman" />
  141. <a:font script="Thai" typeface="Tahoma" />
  142. <a:font script="Ethi" typeface="Nyala" />
  143. <a:font script="Beng" typeface="Vrinda" />
  144. <a:font script="Gujr" typeface="Shruti" />
  145. <a:font script="Khmr" typeface="MoolBoran" />
  146. <a:font script="Knda" typeface="Tunga" />
  147. <a:font script="Guru" typeface="Raavi" />
  148. <a:font script="Cans" typeface="Euphemia" />
  149. <a:font script="Cher" typeface="Plantagenet Cherokee" />
  150. <a:font script="Yiii" typeface="Microsoft Yi Baiti" />
  151. <a:font script="Tibt" typeface="Microsoft Himalaya" />
  152. <a:font script="Thaa" typeface="MV Boli" />
  153. <a:font script="Deva" typeface="Mangal" />
  154. <a:font script="Telu" typeface="Gautami" />
  155. <a:font script="Taml" typeface="Latha" />
  156. <a:font script="Syrc" typeface="Estrangelo Edessa" />
  157. <a:font script="Orya" typeface="Kalinga" />
  158. <a:font script="Mlym" typeface="Kartika" />
  159. <a:font script="Laoo" typeface="DokChampa" />
  160. <a:font script="Sinh" typeface="Iskoola Pota" />
  161. <a:font script="Mong" typeface="Mongolian Baiti" />
  162. <a:font script="Viet" typeface="Times New Roman" />
  163. <a:font script="Uigh" typeface="Microsoft Uighur" />
  164. <a:font script="Geor" typeface="Sylfaen" />
  165. <a:font script="Armn" typeface="Arial" />
  166. <a:font script="Bugi" typeface="Leelawadee UI" />
  167. <a:font script="Bopo" typeface="Microsoft JhengHei" />
  168. <a:font script="Java" typeface="Javanese Text" />
  169. <a:font script="Lisu" typeface="Segoe UI" />
  170. <a:font script="Mymr" typeface="Myanmar Text" />
  171. <a:font script="Nkoo" typeface="Ebrima" />
  172. <a:font script="Olck" typeface="Nirmala UI" />
  173. <a:font script="Osma" typeface="Ebrima" />
  174. <a:font script="Phag" typeface="Phagspa" />
  175. <a:font script="Syrn" typeface="Estrangelo Edessa" />
  176. <a:font script="Syrj" typeface="Estrangelo Edessa" />
  177. <a:font script="Syre" typeface="Estrangelo Edessa" />
  178. <a:font script="Sora" typeface="Nirmala UI" />
  179. <a:font script="Tale" typeface="Microsoft Tai Le" />
  180. <a:font script="Talu" typeface="Microsoft New Tai Lue" />
  181. <a:font script="Tfng" typeface="Ebrima" />
  182. </a:majorFont>
  183. <a:minorFont>
  184. <a:latin typeface="Calibri" panose="020F0502020204030204" />
  185. <a:ea typeface="" />
  186. <a:cs typeface="" />
  187. <a:font script="Jpan" typeface="游ゴシック" />
  188. <a:font script="Hang" typeface="맑은 고딕" />
  189. <a:font script="Hans" typeface="等线" />
  190. <a:font script="Hant" typeface="新細明體" />
  191. <a:font script="Arab" typeface="Arial" />
  192. <a:font script="Hebr" typeface="Arial" />
  193. <a:font script="Thai" typeface="Tahoma" />
  194. <a:font script="Ethi" typeface="Nyala" />
  195. <a:font script="Beng" typeface="Vrinda" />
  196. <a:font script="Gujr" typeface="Shruti" />
  197. <a:font script="Khmr" typeface="DaunPenh" />
  198. <a:font script="Knda" typeface="Tunga" />
  199. <a:font script="Guru" typeface="Raavi" />
  200. <a:font script="Cans" typeface="Euphemia" />
  201. <a:font script="Cher" typeface="Plantagenet Cherokee" />
  202. <a:font script="Yiii" typeface="Microsoft Yi Baiti" />
  203. <a:font script="Tibt" typeface="Microsoft Himalaya" />
  204. <a:font script="Thaa" typeface="MV Boli" />
  205. <a:font script="Deva" typeface="Mangal" />
  206. <a:font script="Telu" typeface="Gautami" />
  207. <a:font script="Taml" typeface="Latha" />
  208. <a:font script="Syrc" typeface="Estrangelo Edessa" />
  209. <a:font script="Orya" typeface="Kalinga" />
  210. <a:font script="Mlym" typeface="Kartika" />
  211. <a:font script="Laoo" typeface="DokChampa" />
  212. <a:font script="Sinh" typeface="Iskoola Pota" />
  213. <a:font script="Mong" typeface="Mongolian Baiti" />
  214. <a:font script="Viet" typeface="Arial" />
  215. <a:font script="Uigh" typeface="Microsoft Uighur" />
  216. <a:font script="Geor" typeface="Sylfaen" />
  217. <a:font script="Armn" typeface="Arial" />
  218. <a:font script="Bugi" typeface="Leelawadee UI" />
  219. <a:font script="Bopo" typeface="Microsoft JhengHei" />
  220. <a:font script="Java" typeface="Javanese Text" />
  221. <a:font script="Lisu" typeface="Segoe UI" />
  222. <a:font script="Mymr" typeface="Myanmar Text" />
  223. <a:font script="Nkoo" typeface="Ebrima" />
  224. <a:font script="Olck" typeface="Nirmala UI" />
  225. <a:font script="Osma" typeface="Ebrima" />
  226. <a:font script="Phag" typeface="Phagspa" />
  227. <a:font script="Syrn" typeface="Estrangelo Edessa" />
  228. <a:font script="Syrj" typeface="Estrangelo Edessa" />
  229. <a:font script="Syre" typeface="Estrangelo Edessa" />
  230. <a:font script="Sora" typeface="Nirmala UI" />
  231. <a:font script="Tale" typeface="Microsoft Tai Le" />
  232. <a:font script="Talu" typeface="Microsoft New Tai Lue" />
  233. <a:font script="Tfng" typeface="Ebrima" />
  234. </a:minorFont>
  235. </a:fontScheme>
  236. <a:fmtScheme name="Office">
  237. <a:fillStyleLst>
  238. <a:solidFill>
  239. <a:schemeClr val="phClr" />
  240. </a:solidFill>
  241. <a:gradFill rotWithShape="1">
  242. <a:gsLst>
  243. <a:gs pos="0">
  244. <a:schemeClr val="phClr">
  245. <a:lumMod val="110000" />
  246. <a:satMod val="105000" />
  247. <a:tint val="67000" />
  248. </a:schemeClr>
  249. </a:gs>
  250. <a:gs pos="50000">
  251. <a:schemeClr val="phClr">
  252. <a:lumMod val="105000" />
  253. <a:satMod val="103000" />
  254. <a:tint val="73000" />
  255. </a:schemeClr>
  256. </a:gs>
  257. <a:gs pos="100000">
  258. <a:schemeClr val="phClr">
  259. <a:lumMod val="105000" />
  260. <a:satMod val="109000" />
  261. <a:tint val="81000" />
  262. </a:schemeClr>
  263. </a:gs>
  264. </a:gsLst>
  265. <a:lin ang="5400000" scaled="0" />
  266. </a:gradFill>
  267. <a:gradFill rotWithShape="1">
  268. <a:gsLst>
  269. <a:gs pos="0">
  270. <a:schemeClr val="phClr">
  271. <a:satMod val="103000" />
  272. <a:lumMod val="102000" />
  273. <a:tint val="94000" />
  274. </a:schemeClr>
  275. </a:gs>
  276. <a:gs pos="50000">
  277. <a:schemeClr val="phClr">
  278. <a:satMod val="110000" />
  279. <a:lumMod val="100000" />
  280. <a:shade val="100000" />
  281. </a:schemeClr>
  282. </a:gs>
  283. <a:gs pos="100000">
  284. <a:schemeClr val="phClr">
  285. <a:lumMod val="99000" />
  286. <a:satMod val="120000" />
  287. <a:shade val="78000" />
  288. </a:schemeClr>
  289. </a:gs>
  290. </a:gsLst>
  291. <a:lin ang="5400000" scaled="0" />
  292. </a:gradFill>
  293. </a:fillStyleLst>
  294. <a:lnStyleLst>
  295. <a:ln w="6350" cap="flat" cmpd="sng" algn="ctr">
  296. <a:solidFill>
  297. <a:schemeClr val="phClr" />
  298. </a:solidFill>
  299. <a:prstDash val="solid" />
  300. <a:miter lim="800000" />
  301. </a:ln>
  302. <a:ln w="12700" cap="flat" cmpd="sng" algn="ctr">
  303. <a:solidFill>
  304. <a:schemeClr val="phClr" />
  305. </a:solidFill>
  306. <a:prstDash val="solid" />
  307. <a:miter lim="800000" />
  308. </a:ln>
  309. <a:ln w="19050" cap="flat" cmpd="sng" algn="ctr">
  310. <a:solidFill>
  311. <a:schemeClr val="phClr" />
  312. </a:solidFill>
  313. <a:prstDash val="solid" />
  314. <a:miter lim="800000" />
  315. </a:ln>
  316. </a:lnStyleLst>
  317. <a:effectStyleLst>
  318. <a:effectStyle>
  319. <a:effectLst />
  320. </a:effectStyle>
  321. <a:effectStyle>
  322. <a:effectLst />
  323. </a:effectStyle>
  324. <a:effectStyle>
  325. <a:effectLst>
  326. <a:outerShdw blurRad="57150" dist="19050" dir="5400000" algn="ctr" rotWithShape="0">
  327. <a:srgbClr val="000000">
  328. <a:alpha val="63000" />
  329. </a:srgbClr>
  330. </a:outerShdw>
  331. </a:effectLst>
  332. </a:effectStyle>
  333. </a:effectStyleLst>
  334. <a:bgFillStyleLst>
  335. <a:solidFill>
  336. <a:schemeClr val="phClr" />
  337. </a:solidFill>
  338. <a:solidFill>
  339. <a:schemeClr val="phClr">
  340. <a:tint val="95000" />
  341. <a:satMod val="170000" />
  342. </a:schemeClr>
  343. </a:solidFill>
  344. <a:gradFill rotWithShape="1">
  345. <a:gsLst>
  346. <a:gs pos="0">
  347. <a:schemeClr val="phClr">
  348. <a:tint val="93000" />
  349. <a:satMod val="150000" />
  350. <a:shade val="98000" />
  351. <a:lumMod val="102000" />
  352. </a:schemeClr>
  353. </a:gs>
  354. <a:gs pos="50000">
  355. <a:schemeClr val="phClr">
  356. <a:tint val="98000" />
  357. <a:satMod val="130000" />
  358. <a:shade val="90000" />
  359. <a:lumMod val="103000" />
  360. </a:schemeClr>
  361. </a:gs>
  362. <a:gs pos="100000">
  363. <a:schemeClr val="phClr">
  364. <a:shade val="63000" />
  365. <a:satMod val="120000" />
  366. </a:schemeClr>
  367. </a:gs>
  368. </a:gsLst>
  369. <a:lin ang="5400000" scaled="0" />
  370. </a:gradFill>
  371. </a:bgFillStyleLst>
  372. </a:fmtScheme>
  373. </a:themeElements>
  374. <a:objectDefaults />
  375. <a:extraClrSchemeLst />
  376. <a:extLst>
  377. <a:ext uri="{00000000-0001-0000-0000-000000000000}">
  378. <thm15:themeFamily
  379. xmlns:thm15="http://schemas.microsoft.com/office/thememl/2012/main"
  380. name="Office Theme"
  381. id="{00000000-0000-0000-0000-000000000000}"
  382. vid="{00000000-0001-0000-0000-000000000000}" />
  383. </a:ext>
  384. </a:extLst>
  385. </a:theme>
  386. `;
  387. export {
  388. stylesData,
  389. theme1Data
  390. }

-end-

手写OOXML文档——导出xlsx格式表格文档的更多相关文章

  1. 十七 bootstrap-table tableExport 导出xlsx格式表格

    原文:十七 bootstrap-table tableExport 导出xlsx格式表格 在[十六.bootstrap-table javascript导出数据]中,打开导出的表格时,总会弹出一个提示 ...

  2. NPOI 2.1.1 系列(1) 使用NPOI读取 Excel文档 ;NpoiExcelHelper 导入导出 2003格式 2007格式的 Excel; Npoi 导出 xlsx 格式

    下载地址 http://npoi.codeplex.com/releases 下面放一个 NPOIHelper 助手类吧,也不是我写的- NpoiExcelHelper 可以生成xlsx格式publi ...

  3. C# Aspose.Cells导出xlsx格式Excel,打开文件报“Excel 已完成文件级验证和修复。此工作簿的某些部分可能已被修复或丢弃”

    报错信息: 最近打开下载的 Excel,会报如下错误.(xls 格式不受影响) 解决方案: 下载代码(红色为新添代码) public void download() { string fileName ...

  4. asp.net NPOI导出xlsx格式文件,打开文件报“Excel 已完成文件级验证和修复。此工作簿的某些部分可能已被修复或丢弃”

    NPOI导出xlsx格式文件,会出现如下情况: 点击“是”: 导出代码如下: /// <summary> /// 将datatable数据写入excel并下载 /// </summa ...

  5. Vue+element 实现文件导出xlsx格式

    傻瓜教程:   第一步:安装两个依赖包 npm install --save xlsx file-saver 第二步:建立一个Vue文件,导入以下代码即可 <template> <d ...

  6. asp.net mvc用aspose.cells 导出xlsx格式的excel。无残留

    public void Export() { HttpResponse Response = System.Web.HttpContext.Current.Response; // Load your ...

  7. 使用Apache POI导出Excel小结--导出XLS格式文档

    使用Apache POI导出Excel小结 关于使用Apache POI导出Excel我大概会分三篇文章去写 使用Apache POI导出Excel小结--导出XLS格式文档 使用Apache POI ...

  8. NPOI 2.1.1 系列(2) 使用NPOI读取List或者datatable数据生成 Excel文档 ;Npoi生成 xlsx 2007以上文档

    结合上一篇文章  NPOI 2.1.1 系列(1) 使用NPOI读取 Excel文档 ;NpoiExcelHelper 导入导出 2003格式 2007格式的 Excel; Npoi 导出 xlsx ...

  9. Anakia 转换xml文档为其他格式

    一.简介 Anakia 使用JDOM 和Velocity将XML文档转换为特定格式的文档 二.解析xml文档方法 1.DOM java jdk,xml-api.jar 需要加载整个xml文档来构建层次 ...

随机推荐

  1. 关于git远程被覆盖的问题

    有同事A和B,git远程版本为A0,两个人的本地项目已经跟远程同步.同事A先向git提交了3次,A1.A2.A3.git远程版本为A0.A1.A2.A3.同事B也向git提交了1次B1,但是同事B提交 ...

  2. JDK8时间工具类

    JDK8添加了java.time包,提供了很多方便.用得比较多的几个类:Instant 在时间线上模拟单个瞬时点Duration 以秒和纳秒为单位模拟一个数量或时间量.可以使用其他基于持续时间的单位访 ...

  3. 《clean code》讲述代码中的道,而不是术

    Clean code 看<clean code>一书,学习高手写出的代码,简单高效的代 1.目标 Bjarne Stroustrup:优雅且高效:直截了当:减少依赖:只做好一件事 Grad ...

  4. android View的测量和绘制

    本篇内容来源于android 群英传(徐易生著) 我写到这里,是觉得徐易生讲的确实很好, 另外加入了一些自己的理解,便于自己基础的提高. 另外参考:http://www.gcssloop.com/cu ...

  5. JAVA父类的静态方法能否被子类重写?

    静态: 在编译时所分配的内存会一直存在(不会被回收),直到程序退出内存才会释放这个空间,在实例化之前这个方法就已经存在于内存,跟类的对象没什么关系.子类中如果定义了相同名称的静态方法,并不会重写,而应 ...

  6. apache ignite系列(九):ignite调优

    1,配置文件调优 1.1 设置页面大小(pagesize) 先查看系统pagesiz,使用PAGE_SIZE或者PAGESIZE # getconf PAGE_SIZE 4096 # getconf ...

  7. Tempter of the Bone(DFS+剪枝)

    Problem Description The doggie found a bone in an ancient maze, which fascinated him a lot. However, ...

  8. .Net Standard(.Net Core)实现获取配置信息

    一.前言 在.Net Framework框架有专门获取webconfig配置的方法供我们使用,但是在.Net Core或者.Net Standard中没有可以直接使用的方法来获取配置文件信息,下面就来 ...

  9. 54 (OC)* 网络七层架构

    一:TCP/IP协议 二:七层协议 1:物理层 物理层为设备之间的数据通信提供传输媒体及互连设备,为数据传输提供可靠的环境.  1.1:传输媒体和互连设备        物理层的媒体包括架空明线.平衡 ...

  10. 16 (OC)* UIAnimation和CoreAnimation

    目录 一 Core Animation 二 核心动画 2.1 基础动画 2.2 关键帧动画 2.3 动画组 2.4 转场动画 2.5 逐帧动画 三 UIView动画封装 3.1 基础动画 3.2 弹簧 ...