Il est possible en utilisant les liaisons ONU CLI. Malheureusement, Powershell ne gère pas bien les objets proxy, vous devez donc utiliser la réflexion. Par exemple,
[System.Reflection.Assembly]::LoadWithPartialName('cli_basetypes')
[System.Reflection.Assembly]::LoadWithPartialName('cli_cppuhelper')
[System.Reflection.Assembly]::LoadWithPartialName('cli_oootypes')
[System.Reflection.Assembly]::LoadWithPartialName('cli_ure')
[System.Reflection.Assembly]::LoadWithPartialName('cli_uretypes')
$localContext = [uno.util.Bootstrap]::bootstrap()
$multiComponentFactory = [unoidl.com.sun.star.uno.XComponentContext].getMethod('getServiceManager').invoke($localContext, @())
$desktop = [unoidl.com.sun.star.lang.XMultiComponentFactory].getMethod('createInstanceWithContext').invoke($multiComponentFactory, @('com.sun.star.frame.Desktop', $localContext))
$calc = [unoidl.com.sun.star.frame.XComponentLoader].getMethod('loadComponentFromURL').invoke($desktop, @('private:factory/scalc', '_blank', 0, $null))
$sheets = [unoidl.com.sun.star.sheet.XSpreadsheetDocument].getMethod('getSheets').invoke($calc, @())
$sheet = [unoidl.com.sun.star.container.XIndexAccess].getMethod('getByIndex').invoke($sheets, @(0))
$cell = [unoidl.com.sun.star.table.XCellRange].getMethod('getCellByPosition').invoke($sheet.Value, @(0,0))
[unoidl.com.sun.star.table.XCell].getMethod('setFormula').invoke($cell, @('A value in cell A1.'))
Vous pouvez également essayer AODL qui devrait être beaucoup plus facile à utiliser, mais ne ressemble pas à ça a été récemment mis à jour.
On dirait une dupe de http://stackoverflow.com/questions/954926/using-a-script-to-automate-data-entry-to-an-openoffice-calc-spreadsheet – Helen
Helen, Non, la question http://stackoverflow.com/questions/954926/using-a-script-to-automate-data-entry-to-an-openoffice-calc-spreadsheet est basé sur n'importe quel script; celui-ci est spécifique à PowerShell. Vu le manque de réponse à cette question, j'ai ouvert la seconde. – MagicAndi
une solution finale avec un exemple de code source complet à ce sujet? – Kiquenet