简体   繁体   English

package 多个 openxml 格式 xml 如何仅使用字符串转换为一个没有 OpenXml SDK 的 xlsx 文件?

[英]How package multiple openxml format xml to one xlsx file without OpenXml SDK just using string?

How package multiple openxml format xml to one xlsx file without OpenXml SDK just using string? package 多个 openxml 格式 xml 如何仅使用字符串转换为一个没有 OpenXml SDK 的 xlsx 文件?

There're three xml like image, I'd like to package then to one xlsx without OpenXml SDK .有三个 xml 类似图像,我想 package 然后一个 xlsx without OpenXml SDK

I've tried create file and folder like我试过创建文件和文件夹

package them to zip file and rename Test.xlsx package 到zip文件并重命名Test.xlsx
but it not work and show file error.但它不起作用并显示文件错误。

Three xml files data:三个xml文件数据:

/docProps/app.xml

<ap:Properties xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes" xmlns:ap="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties">
  <ap:Application>Microsoft Excel</ap:Application>
  <ap:DocSecurity>0</ap:DocSecurity>
  <ap:ScaleCrop>false</ap:ScaleCrop>
  <ap:HeadingPairs>
    <vt:vector baseType="variant" size="2">
      <vt:variant>
        <vt:lpstr>Worksheets</vt:lpstr>
      </vt:variant>
      <vt:variant>
        <vt:i4>1</vt:i4>
      </vt:variant>
    </vt:vector>
  </ap:HeadingPairs>
  <ap:TitlesOfParts>
    <vt:vector baseType="lpstr" size="1">
      <vt:lpstr>Sheet1</vt:lpstr>
    </vt:vector>
  </ap:TitlesOfParts>
  <ap:Company />
  <ap:LinksUpToDate>false</ap:LinksUpToDate>
  <ap:SharedDoc>false</ap:SharedDoc>
  <ap:HyperlinksChanged>false</ap:HyperlinksChanged>
  <ap:AppVersion>16.0300</ap:AppVersion>
</ap:Properties>

/docProps/core.xml

<?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>Wei</dc:creator><cp:lastModifiedBy>Wei</cp:lastModifiedBy><dcterms:created xsi:type="dcterms:W3CDTF">2015-06-05T18:17:20Z</dcterms:created><dcterms:modified xsi:type="dcterms:W3CDTF">2021-02-23T07:31:31Z</dcterms:modified></cp:coreProperties>

/xl/workbook.xml

<x:styleSheet xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 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" mc:Ignorable="x14ac x16r2 xr" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
  <x:fonts count="2" x14ac:knownFonts="1">
    <x:font>
      <x:sz val="11" />
      <x:color theme="1" />
      <x:name val="Calibri" />
      <x:family val="2" />
      <x:scheme val="minor" />
    </x:font>
    <x:font>
      <x:sz val="8" />
      <x:name val="Calibri" />
      <x:family val="2" />
      <x:scheme val="minor" />
    </x:font>
  </x:fonts>
  <x:fills count="2">
    <x:fill>
      <x:patternFill patternType="none" />
    </x:fill>
    <x:fill>
      <x:patternFill patternType="gray125" />
    </x:fill>
  </x:fills>
  <x:borders count="1">
    <x:border>
      <x:left />
      <x:right />
      <x:top />
      <x:bottom />
      <x:diagonal />
    </x:border>
  </x:borders>
  <x:cellStyleXfs count="1">
    <x:xf numFmtId="0" fontId="0" fillId="0" borderId="0" />
  </x:cellStyleXfs>
  <x:cellXfs count="1">
    <x:xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" />
  </x:cellXfs>
  <x:cellStyles count="1">
    <x:cellStyle name="Normal" xfId="0" builtinId="0" />
  </x:cellStyles>
  <x:dxfs count="0" />
  <x:tableStyles count="0" defaultTableStyle="TableStyleMedium2" defaultPivotStyle="PivotStyleLight16" />
  <x:extLst>
    <x:ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}">
      <x14:slicerStyles defaultSlicerStyle="SlicerStyleLight1" />
    </x:ext>
    <x:ext xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main" uri="{9260A510-F301-46a8-8635-F512D64BE5F5}">
      <x15:timelineStyles defaultTimelineStyle="TimeSlicerStyleLight1" />
    </x:ext>
  </x:extLst>
</x:styleSheet>
<a:theme xmlns:thm15="http://schemas.microsoft.com/office/thememl/2012/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme">
  <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="5B9BD5" />
      </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="4472C4" />
      </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: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: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>
<x:worksheet xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 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="{00000000-0001-0000-0000-000000000000}" mc:Ignorable="x14ac xr xr2 xr3" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
  <x:dimension ref="A1:C4" />
  <x:sheetViews>
    <x:sheetView tabSelected="1" workbookViewId="0">
      <x:selection activeCell="E5" sqref="E5" />
    </x:sheetView>
  </x:sheetViews>
  <x:sheetFormatPr defaultRowHeight="14.4" x14ac:dyDescent="0.3" />
  <x:sheetData>
    <x:row r="1" spans="1:3" x14ac:dyDescent="0.3">
      <x:c r="A1" t="s">
        <x:v>0</x:v>
      </x:c>
      <x:c r="B1" t="s">
        <x:v>1</x:v>
      </x:c>
      <x:c r="C1" t="s">
        <x:v>2</x:v>
      </x:c>
    </x:row>
    <x:row r="2" spans="1:3" x14ac:dyDescent="0.3">
      <x:c r="A2" t="s">
        <x:v>3</x:v>
      </x:c>
      <x:c r="B2" t="s">
        <x:v>4</x:v>
      </x:c>
      <x:c r="C2" t="s">
        <x:v>5</x:v>
      </x:c>
    </x:row>
    <x:row r="3" spans="1:3" x14ac:dyDescent="0.3">
      <x:c r="A3" t="s">
        <x:v>6</x:v>
      </x:c>
      <x:c r="B3" t="s">
        <x:v>7</x:v>
      </x:c>
      <x:c r="C3" t="s">
        <x:v>8</x:v>
      </x:c>
    </x:row>
    <x:row r="4" spans="1:3" x14ac:dyDescent="0.3">
      <x:c r="A4" t="s">
        <x:v>9</x:v>
      </x:c>
      <x:c r="B4" t="s">
        <x:v>10</x:v>
      </x:c>
      <x:c r="C4" t="s">
        <x:v>11</x:v>
      </x:c>
    </x:row>
  </x:sheetData>
  <x:phoneticPr fontId="1" type="noConversion" />
  <x:pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3" />
</x:worksheet>
<x:sst count="12" uniqueCount="12" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
  <x:si>
    <x:t>A1</x:t>
  </x:si>
  <x:si>
    <x:t>B1</x:t>
  </x:si>
  <x:si>
    <x:t>C1</x:t>
  </x:si>
  <x:si>
    <x:t>A2</x:t>
  </x:si>
  <x:si>
    <x:t>B2</x:t>
  </x:si>
  <x:si>
    <x:t>C2</x:t>
  </x:si>
  <x:si>
    <x:t>A3</x:t>
  </x:si>
  <x:si>
    <x:t>B3</x:t>
  </x:si>
  <x:si>
    <x:t>C3</x:t>
  </x:si>
  <x:si>
    <x:t>A4</x:t>
  </x:si>
  <x:si>
    <x:t>B4</x:t>
  </x:si>
  <x:si>
    <x:t>C4</x:t>
  </x:si>
</x:sst>
<x:workbook xmlns:x15ac="http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 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" mc:Ignorable="x15 xr xr6 xr10 xr2" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
  <x:fileVersion appName="xl" lastEdited="7" lowestEdited="6" rupBuild="23628" />
  <x:workbookPr />
  <mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
    <mc:Choice Requires="x15">
      <x15ac:absPath xmlns:x15ac="http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac" url="D:\demos\2021-02-23 OpenXmlSheetDemo\" />
    </mc:Choice>
  </mc:AlternateContent>
  <xr:revisionPtr revIDLastSave="0" documentId="13_ncr:1_{E054103D-6836-43D1-8070-43C5CB7C85D0}" xr6:coauthVersionLast="46" xr6:coauthVersionMax="46" xr10:uidLastSave="{00000000-0000-0000-0000-000000000000}" />
  <x:bookViews>
    <x:workbookView xWindow="-108" yWindow="-108" windowWidth="23256" windowHeight="12720" xr2:uid="{00000000-000D-0000-FFFF-FFFF00000000}" />
  </x:bookViews>
  <x:sheets>
    <x:sheet name="Sheet1" sheetId="1" r:id="rId1" />
  </x:sheets>
  <x:calcPr calcId="162913" />
  <x:extLst>
    <x:ext xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main" uri="{140A7094-0E35-4892-8432-C4D2E57EDEB5}">
      <x15:workbookPr chartTrackingRefBase="1" />
    </x:ext>
  </x:extLst>
</x:workbook>

I resolve problem by below way.我通过以下方式解决问题。

Step1.步骤1。 Folder tree path have to like:文件夹树路径必须喜欢:

│   [Content_Types].xml
│
├───docProps
│       app.xml
│       core.xml
│
├───xl
│   │   sharedStrings.xml
│   │   styles.xml
│   │   workbook.xml
│   │
│   ├───theme
│   │       theme1.xml
│   │
│   ├───worksheets
│   │       sheet1.xml
│   │
│   └───_rels
│           workbook.xml.rels
│
└───_rels
        .rels

Step2.第2步。 then from root folder path to zip all folder and files to zip file and rename to Demo.xlsx然后从根文件夹路径到 zip 所有文件夹和文件到 zip 文件并重命名为Demo.xlsx

Result:结果:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM