0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Excelのセルに配置した画像(セル内画像)取得の備忘録

Last updated at Posted at 2025-10-04

Excel2019あたりから、セルに画像を配置する機能が追加されたが
古いOfficeではこの機能に対応していないのでExcelを開いた際に
エラーが出る。

xlsxファイルを解凍してsheet*.xmlの情報から、cellのタイプが
エラーでかつvm(ValueMetadata)の値を持っているとセルに画像が
配置されていることを確認した。
Image関数を利用した場合でも同様の情報を保持

sheet*.xml
 <c r="B1" t="e" vm="1">

このvmの値と、metadata.xmlが持つ値を突き合わせてから
richValueの値を参照すればどの画像が参照されているかを
取得できそう。

まず、metadata.xml

metadata.xml
<valueMetadata count="2">
 <bk>
  <rc t="1" v="0"/>
 </bk>
 <bk>
  <rc t="1" v="1"/>
 </bk>
</valueMetadata>

の部分を1開始番号で取得( vm=1なら一つ目みたいに個数で取得? )して、rcタグのv値を格納

そのあと、

metadata.xml
<futureMetadata name="XLRICHVALUE" count="2">
 <bk>
  <extLst>
   <ext uri="{3e2802c4-a4d2-4d8b-9148-e3be6c30e623}">
    <xlrd:rvb i="0"/>
   </ext>
  </extLst>
 </bk>
 <bk>
  <extLst>
   <ext uri="{3e2802c4-a4d2-4d8b-9148-e3be6c30e623}">
    <xlrd:rvb i="1"/>
   </ext>
  </extLst>
 </bk>
</futureMetadata>

を 0 indexで取得して、のiの値を取得
んで、rdrichvaluestructure.xmlの情報を参照( 0 index )

rdrichvaluestructure.xml
<rvStructures xmlns="http://schemas.microsoft.com/office/spreadsheetml/2017/richdata" count="2">
 <s t="_webimage">
  <k n="WebImageIdentifier" t="i"/>
  <k n="CalcOrigin" t="i"/>
  <k n="ComputedImage" t="b"/>
  <k n="ImageSizing" t="i"/>
  <k n="Text" t="s"/>
 </s>
 <s t="_localImage">
  <k n="_rvRel:LocalImageIdentifier" t="i"/> 
  <k n="CalcOrigin" t="i"/>
 </s>
</rvStructures>

WebImageIdentifier = rdRichValueWebImage.xml で紐づいて、
_rvRel:LocalImageIdentifier = richValueRel.xml が紐づいてる? ( _rvRelがそう? )

rdrichvalue.xml
<rvData xmlns="http://schemas.microsoft.com/office/spreadsheetml/2017/richdata" count="2">
 <rv s="0">
  <v>0</v>	
  <v>1</v>
  <v>0</v>
  <v>0</v>
  <v></v>
 </rv>
 <rv s="1">
  <v>0</v>
  <v>5</v>
 </rv>
</rvData>

がrdrichvaluestructureのindex番号に紐づけ?
vタグはrdrichvaluestructureのk(Key)に対するValue
Valueタグのそれぞれの数値の役割が調べきれなかった。
TypeのIndex番号なんだと思うけど。

richValueRel.xmlとrdRichValueWebImage.xmlからridを取得し、_relsディレクトリ内の
richValueRel.xml.rels
rdRichValueWebImage.xml.rels
からそれぞれ紐づいた画像名を確認する
rdRichValueWebImage.xmlはblipタグのr:idがそうだと思う

あとはridから確認した画像名をmediaディレクトリから取得する

セルに画像の配置やimage関数を未使用の場合、それぞれに関連するタグは出力されない。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?