Version: 7.3.7.2
住所から郵便番号を返すWebAPIの結果をWEBSERVICE関数でセルに表示する。下記はExcelAPIを利用する関数の使用例。
=WEBSERVICE("http://api.excelapi.org/post/zipcode?address="&ENCODEURL(A1))
人生の最終目標は気ままな老後生活
Version: 7.3.7.2
住所から郵便番号を返すWebAPIの結果をWEBSERVICE関数でセルに表示する。下記はExcelAPIを利用する関数の使用例。
=WEBSERVICE("http://api.excelapi.org/post/zipcode?address="&ENCODEURL(A1))
Dim args(2) as new com.sun.star.beans.PropertyValue args(0).Name = "PrintArea" args(0).Value = "$A$1:$U$30" args(1).Name = "PrintRepeatRow" args(1).Value = "$A$10" args(2).Name = "PrintRepeatCol" args(2).Value = "" Dim dispatcher as Object dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") dispatcher.executeDispatch(ThisComponent.CurrentController.Frame, ".uno:ChangePrintArea", "", 0, args())
Calcを使用して「test.ods」から「呼び出されるドキュメント.ods」のFunctionを呼び出して結果を取得するのが目的。Version: LibreOffice 6.4.7.2
呼び出されるドキュメント.odsのFunctionは下記の通り。
Function Test(a, b) Print a b = "test3" Test = 1 End Function
test.odsから呼び出して結果を取得する。
Dim document As Object document = StarDesktop.loadComponentFromURL(ConvertToUrl("/home/user/Desktop/呼び出されるドキュメント.ods"), "_blank", 0, Array()) Dim scriptProvider As Object scriptProvider = document.getScriptProvider() Dim url As String url ="vnd.sun.star.script:Standard.Module1.Test?language=Basic&location=document" Dim script As Object script = scriptProvider.getScript(url) Dim args As Object args = array("test1", "test2") Dim argsAfterFinishing As Object argsAfterFinishing = array() 'test1と1が表示される Print script.invoke(args, 0, argsAfterFinishing) 'test2が表示される Print args(1) 'test3が表示される Print argsAfterFinishing(1)
ThisComponent.enableautomaticCalculation False
「ツール」→「マクロ」→「ダイアログの管理」から追加した”Dialog1″を表示してダイアログ内のテキストフィールドの値を取得するコード。ちなみにダイアログをコードで閉じるにはdialogオブジェクトのendexecute()メソッドを呼ぶ。
'Show dialog DialogLibraries.LoadLibrary("Standard") dialog = CreateUnoDialog(DialogLibraries.Standard.Dialog1) dialog.execute() 'Get text Dim textField As Object textField = dialog.getControl("TextField1") Dim value As String value = textField.getText()
Dim validation As Object validation = ThisComponent.Sheets.getByIndex(0).getColumns.getByIndex(5).Validation validation.Type = com.sun.star.sheet.ValidationType.ANY ThisComponent.Sheets.getByIndex(0).getColumns.getByIndex(5).Validation = validation
Dim startRow As Integer startRow = ThisComponent.CurrentSelection.RangeAddress.StartRow Dim endRow As Integer 'endRowは2になる endRow = ThisComponent.Sheets.getByIndex(0).getCellRangeByName("A1:A3").RangeAddress.EndRow Dim startColumn As Integer 'startColumnは1になる startColumn = ThisComponent.Sheets.getByName("sheet1").getCellRangeByName("B1:C6").RangeAddress.StartColumn Dim endColumn As Integer 'endColumnは3になる endColumn = ThisComponent.Sheets.getByName("sheet2").getCellRangeByName("A1:D9").RangeAddress.EndColumn
Dim fileLocation As String Dim directory As String fileLocation = ConvertFromURL(ThisComponent.getLocation()) directory = Left(fileLocation, Len(fileLocation) - Len(ThisComponent.getTitle())) MsgBox(directory)
Dim styleFamilies As Object Dim styles As Object Dim style As Object styleFamilies = ThisComponent.StyleFamilies styles = styleFamilies.getByName("PageStyles") style = styles.getByName("標準") style.HeaderIsOn = false 'ヘッダーOFF style.FooterIsOn = false 'フッターOFF style.CenterHorizontally = true '横方向中央配置 style.Height = 25000 '用紙高さ250mm style.Width = 17600 '用紙幅176mm style.scaleToPages = 1 '1ページに収める
プロパティ | 型 |
---|---|
CenterHorizontally | boolean |
CenterVertically | boolean |
PrintAnnotations | boolean |
PrintGrid | boolean |
PrintHeaders | boolean |
PrintCharts | boolean |
PrintObjects | boolean |
PrintDrawing | boolean |
PrintFormulas | boolean |
PrintZeroValues | boolean |
PrintDownFirst | boolean |
LeftPageHeaderContent | XHeaderFooterContent |
LeftPageFooterContent | XHeaderFooterContent |
RightPageHeaderContent | XHeaderFooterContent |
RightPageFooterContent | XHeaderFooterContent |
FirstPageNumber | short |
PageScale | short |
ScaleToPages | short |
ScaleToPagesX | short |
ScaleToPagesY | short |
BackColor | ::com::sun::star::util::Color |
BackGraphicURL | string |
BackGraphicFilter | string |
BackGraphicLocation | GraphicLocation |
BackTransparent | boolean |
LeftMargin | long |
RightMargin | long |
TopMargin | long |
BottomMargin | long |
LeftBorder | ::com::sun::star::table::BorderLine |
RightBorder | ::com::sun::star::table::BorderLine |
TopBorder | ::com::sun::star::table::BorderLine |
BottomBorder | ::com::sun::star::table::BorderLine |
LeftBorderDistance | long |
RightBorderDistance | long |
TopBorderDistance | long |
BottomBorderDistance | long |
ShadowFormat | ::com::sun::star::table::ShadowFormat |
IsLandscape | boolean |
NumberingType | short |
PageStyleLayout | PageStyleLayout |
PrinterPaperTray | string |
RegisterModeActive | boolean |
RegisterParagraphStyle | string |
Size | ::com::sun::star::awt::Size |
Width | long |
Height | long |
TextColumns | ::com::sun::star::text::XTextColumns |
UserDefinedAttributes | ::com::sun::star::container::XNameContainer |
HeaderBackColor | [ maybevoid ] ::com::sun::star::util::Color |
HeaderBackGraphicURL | [ maybevoid ] string |
HeaderBackGraphicFilter | [ maybevoid ] string |
HeaderBackGraphicLocation | [ maybevoid ] GraphicLocation |
HeaderLeftMargin | [ maybevoid ] long |
HeaderRightMargin | [ maybevoid ] long |
HeaderBackTransparent | [ maybevoid ] boolean |
HeaderLeftBorder | [ maybevoid ] ::com::sun::star::table::BorderLine |
HeaderRightBorder | [ maybevoid ] ::com::sun::star::table::BorderLine |
HeaderTopBorder | [ maybevoid ] ::com::sun::star::table::BorderLine |
HeaderBottomBorder | [ maybevoid ] ::com::sun::star::table::BorderLine |
HeaderLeftBorderDistance | [ maybevoid ] long |
HeaderRightBorderDistance | [ maybevoid ] long |
HeaderTopBorderDistance | [ maybevoid ] long |
HeaderBottomBorderDistance | [ maybevoid ] long |
HeaderShadowFormat | [ maybevoid ] ::com::sun::star::table::ShadowFormat |
HeaderBodyDistance | [ maybevoid ] long |
HeaderIsShared | [ maybevoid ] boolean |
HeaderHeight | [ maybevoid ] long |
HeaderIsDynamicHeight | [ maybevoid ] boolean |
HeaderIsOn | boolean |
HeaderText | [ maybevoid ] ::com::sun::star::text::XText |
HeaderTextLeft | [ maybevoid ] ::com::sun::star::text::XText |
HeaderTextRight | [ maybevoid ] ::com::sun::star::text::XText |
FooterBackColor | [ maybevoid ] ::com::sun::star::util::Color |
FooterBackGraphicURL | [ maybevoid ] string |
FooterBackGraphicFilter | [ maybevoid ] string |
FooterBackGraphicLocation | [ maybevoid ] GraphicLocation |
FooterLeftMargin | [ maybevoid ] long |
FooterRightMargin | [ maybevoid ] long |
FooterBackTransparent | [ maybevoid ] boolean |
FooterLeftBorder | [ maybevoid ] ::com::sun::star::table::BorderLine |
FooterRightBorder | [ maybevoid ] ::com::sun::star::table::BorderLine |
FooterTopBorder | [ maybevoid ] ::com::sun::star::table::BorderLine |
FooterBottomBorder | [ maybevoid ] ::com::sun::star::table::BorderLine |
FooterLeftBorderDistance | [ maybevoid ] long |
FooterRightBorderDistance | [ maybevoid ] long |
FooterTopBorderDistance | [ maybevoid ] long |
FooterBottomBorderDistance | [ maybevoid ] long |
FooterShadowFormat | [ maybevoid ] ::com::sun::star::table::ShadowFormat |
FooterBodyDistance | [ maybevoid ] long |
FooterIsDynamicHeight | [ maybevoid ] boolean |
FooterIsShared | [ maybevoid ] boolean |
FooterHeight | [ maybevoid ] long |
FooterIsOn | boolean |
FooterText | [ maybevoid ] ::com::sun::star::text::XText |
FooterTextLeft | [ maybevoid ] ::com::sun::star::text::XText |
FooterTextRight | [ maybevoid ] ::com::sun::star::text::XText |
FootnoteHeight | long |
FootnoteLineWeight | short |
FootnoteLineColor | ::com::sun::star::util::Color |
FootnoteLineRelativeWidth | byte |
FootnoteLineAdjust | short |
FootnoteLineTextDistance | long |
FootnoteLineDistance | long |
WritingMode | short |
GridMode | short |
GridColor | ::com::sun::star::util::Color |
GridLines | short |
GridBaseHeight | long |
GridRubyHeight | long |
GridRubyBelow | boolean |
GridPrint | boolean |
GridDisplay | boolean |
HeaderDynamicSpacing | [ maybevoid ] boolean |
FooterDynamicSpacing | [ maybevoid ] boolean |
BorderDistance | long |
FooterBorderDistance | [ maybevoid ] long |
HeaderBorderDistance | [ maybevoid ] long |
Dim document As Object Dim dispatcher As Object document = ThisComponent.CurrentController.Frame dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") Dim args(1) As new com.sun.star.beans.PropertyValue args(0).Name = "Template" args(0).Value = "標準" args(1).Name = "Family" args(1).Value = 8 'シートに適用する場合は8 dispatcher.executeDispatch(document, ".uno:StyleApply", "", 0, args())