OpenXml——Office2007

到现在之接触了Word2007与Excel2007的xml更改个别属性的问题。
无论是docx或者xlsx的扩展名都可以直接将其改为.zip,并解压出来。解压出来的文件除了在printersettings下有个bin文件以外,其他是xml文件。

1、Word2007产生的文件夹word下存在一个document.xml文件,可以通过对该文件进行操作赋值来达到改变word文档内容的效果。
2、Word2007中可以嵌套Excel表格(假设现在的Excel为2007的版本),解压以后这些表格存在于word/embeddings文件夹下。并且是以Excel文件的形式存在,如果想要修改这些Excel文件的内容,那仍旧是将其解压。

3、Excel2007产生的文件夹xl下存在一个sharedStrings.xml文件,该文件存储单元格中的内容,但并不是所有的内容都存在于该文件中。在worksheets文件夹下的sheet.xml(sheet文件不止一个,对应于Excel文件中的工作簿名称)中

<?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">
  
<dimension ref="A1:M33" />
  
<sheetViews>
    
<sheetView showGridLines="0" tabSelected="1" workbookViewId="0">
      
<selection sqref="A1:E1" />
    
</sheetView>
  
</sheetViews>
  
<sheetFormatPr defaultRowHeight="13.5" />
  
<cols>
    
<col min="1" max="1" width="54.875" style="18" customWidth="1" />
    
<col min="2" max="2" width="1.625" customWidth="1" />
    
<col min="4" max="4" width="2" customWidth="1" />
    
<col min="5" max="5" width="16" customWidth="1" />
    
<col min="13" max="13" width="9" hidden="1" customWidth="1" />
  
</cols>
  
<sheetData>
    
<row r="1" spans="1:5" ht="14.25">
      
<r="A1" s="19" t="s">
        
<v>0</v>
      
</c>
      
<r="B1" s="19" />
      
<r="C1" s="19" />
      
<r="D1" s="19" />
      
<r="E1" s="19" />
    
</row>
    
<row r="2" spans="1:5" ht="15">
      
<r="A2" s="13" />
      
<r="B2" s="1" />
      
<r="C2" s="2" />
      
<r="D2" s="2" />
      
<r="E2" s="2" />
    
</row>
    
<row r="3" spans="1:5">
      
<r="A3" s="14" t="s">
        
<v>1</v>
      
</c>
      
<r="B3" s="3" />
      
<r="C3" s="4" t="s">
        
<v>2</v>
      
</c>
      
<r="D3" s="5" />
      
<r="E3" s="4" t="s">
        
<v>3</v>
      
</c>
    
</row>
  
</sheetData>
  
<mergeCells count="1">
    
<mergeCell ref="A1:E1" />
  
</mergeCells>
  
<phoneticPr fontId="1" type="noConversion" />
  
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3" />
  
<pageSetup paperSize="9" orientation="portrait" r:id="rId1" />
</worksheet>
Cols节点下的col节点可以设置列宽。
row节点下的c节点,如果不存在t属性,则v节点中的值为该单元格的值,如果存在t属性,则v节点中的值对应于SharedStrings.xml文件中的索引。
posted @ 2008-07-01 14:26  JerryShi  阅读(994)  评论(0编辑  收藏  举报