From: wada toshiki Date: 2007-08-28T21:16:52+09:00 Subject: [ruby-list:43952] OpenOffice.org calcの書式を設定するには rubyからOpenOffice.org calcを操作したいのですが、 http://hermione.s41.xrea.com/pukiwiki/pukiwiki.php?OOoBasic を参考に、calcに書き出すことができました。 ----------------------------------------------------------------------- require 'win32ole' serviceManager = WIN32OLE.new("com.sun.star.ServiceManager") desktop = serviceManager.createInstance("com.sun.star.frame.Desktop") oDoc = desktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, []) oSheets = oDoc.getSheets() oSheet = oSheets.getByIndex(0) oCell = oSheet.getCellRangeByName("B2") oCell.Value = 1000 oSheet.getCellRangeByName("C3").Value = 100 ------------------------------------------------------------------------ 次に、セルの数値の書式を小数点以下6桁に設定したいのです。 先の、OpenOffice.org Basic のコードによれば以下のようになっています。 ------------------------------------------------------------------------ Sub numberformats_generateformat() Dim oDocument As Object, oNumberFormats As Object Dim oLocale As New com.sun.star.lang.Locale Dim nBaseKey As Long Dim sFormat As String oDocument = ThisComponent oNumberFormats = oDocument.NumberFormats nBaseKey = oNumberFormats.queryKey( "#,##0", oLocale, False ) If nBaseKey <> -1 Then sFormat = oNumberFormats.generateFormat( nBaseKey, oLocale, _ False, True, 1, 0 ) MsgBox sFormat End If End Sub ------------------------------------------------------------------------ この中の、 Dim oLocale As New com.sun.star.lang.Locale は、rubyでは何にあたるのでしょうか。よろしくお願いします。 -- ********************************************* 和田稔己