[英]Add style (format) to cell of MS Excel document using Ruby with win32ole
By default a cell in MS Excel has format "number". 默认情况下,MS Excel中的单元格格式为“数字”。 If you put value '2/2' to a cell Excel converts it to date.
如果将值“ 2/2”放入单元格,Excel会将其转换为日期。 How to change the format of cell to Text using 'win32ole'?
如何使用“ win32ole”将单元格的格式更改为“文本”? I want to put '2/2' and see exactly '2/2'.
我想输入“ 2/2”,然后准确地看到“ 2/2”。 When I talking about 'win32ole' I mean http://ruby-doc.org/stdlib-1.9.3/libdoc/win32ole/rdoc/WIN32OLE.html
当我谈论'win32ole'时,我的意思是http://ruby-doc.org/stdlib-1.9.3/libdoc/win32ole/rdoc/WIN32OLE.html
I have found the answer. 我找到了答案。 I looked for 'change cell format using VBA'.
我寻找“使用VBA更改单元格格式”。 So the answer:
cell.NumberFormat = '@'
所以答案是:
cell.NumberFormat = '@'
Pretty not obvious. 相当不明显。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.