<p>我使用python2.7.3
我需要用openpyxl库将本地图片的超链接写入单元格。在</p>
<p>当我需要添加到网站的超链接时,我会写如下:</p>
<p>从openpyxl导入工作簿</p>
<pre><code>wb = Workbook()
dest_filename = r'empty_book.xlsx'
ws = wb.worksheets[0]
ws.title = 'Name'
hyperlink to local picture
ws.cell('B1').hyperlink = ('http://pythonhosted.org/openpyxl/api.html')
hyperlink to local picture
ws.cell('B2').hyperlink = ('1.png') # It doesn't work!
wb.save(filename = dest_filename)
</code></pre>
<p>我有三个问题:</p>
<ol>
<li>如何编写类似VBA样式函数的超链接:
<code>ActiveCell.FormulaR1C1 = _
"=HYPERLINK(""http://stackoverflow.com/questions/ask"",""site"")"</code>
还有她的名字</li>
<li>我们怎样才能写到本地图片的超链接?
<code>ws.cell('B2').hyperlink = ('1.png') # It doesn't work! And I don't now what to do )
Plese, help me )</code></li>
<li>我们可以使用unicode超链接到图像吗?例如当我使用
<code>ws.cell('B1').hyperlink =
(u'http://pythonhosted.org/openpyxl/api.html') It fail with error!
for example we have picture 'russian_language_name.png' and we
create hyperlink in exel without any problem. We click to the cell,
and then print
'=Hyperlink("http://stackoverflow.com/questions/ask";"site_by_russian_language")</code></li>
</ol>
<p>保存文件,解压他。然后转到他的目录xl->worksheets->sheet1.xml
我们看到了标题</p>
<p><code><?xml version="1.0" encoding="UTF-8" standalone="true"?></code></p>
<p>然后。。。在</p>
<p><code>row r="2" x14ac:dyDescent="0.25" spans="2:6">-<c r="B2" t="str" s="1"><f>HYPERLINK("http://stackoverflow.com/questions/ask","site_by_russian_language")</f><v>site_by_russian_language</v></c></code></p>
<p>Exel支持unicode,但是python的库openpyxl呢?它支持超链接中的unicode?在</p>