使用Perl或Ruby提取Excel单元格注释的最佳方法是什么? [英] What's the best way to extract Excel cell comments using Perl or Ruby?

查看:50
本文介绍了使用Perl或Ruby提取Excel单元格注释的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用在Perl中解析Excel文件的最佳方法是什么?),但我不知道如何提取单元格注释.

I've been parsing Excel documents in Perl successfully with Spreadhsheet::ParseExcel (as recommended in What's the best way to parse Excel file in Perl?), but I can't figure out how to extract cell comments.

有什么想法吗?使用Perl或Ruby的解决方案将是理想的.

Any ideas? A solution in Perl or Ruby would be ideal.

推荐答案

一种选择是使用Ruby的win32ole库.

One option is to use Ruby's win32ole library.

下面的示例(有点冗长)连接到一个打开的Excel工作表,并从单元格B2中获取注释文本.

The following (somewhat verbose) example connects to an open Excel worksheet and gets the comment text from cell B2.

require 'win32ole'

xl = WIN32OLE.connect('Excel.Application')
ws = xl.ActiveSheet
cell = ws.Range('B2')
comment = cell.Comment
text = comment.Text

可以在这里找到更多信息以及使用Ruby的win32ole库自动执行Excel的示例:

More info and examples of using Ruby's win32ole library to automate Excel can be found here:

http://rubyonwindows.blogspot.com/search/label/excel

这篇关于使用Perl或Ruby提取Excel单元格注释的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆