Click here to Skip to main content
15,886,835 members

Inserting picture in calc using vb.net

evilson asked:

Open original thread
I made an coding to create a open-office calc document using a vb.net
VB
Public Class OoCalc
Public Context As unoidl.com.sun.star.uno.XComponentContext
Public Factory As unoidl.com.sun.star.lang.XMultiServiceFactory
Public Loader As unoidl.com.sun.star.frame.XComponentLoader
Public Doc As unoidl.com.sun.star.sheet.XSpreadsheetDocument
Public Storable As unoidl.com.sun.star.frame.XStorable
Public Model As unoidl.com.sun.star.frame.XModel
Public Sheets As unoidl.com.sun.star.sheet.XSpreadsheets
Public Sheet As unoidl.com.sun.star.sheet.XSpreadsheet
Public Closeable As unoidl.com.sun.star.util.XCloseable
Public FileProps As unoidl.com.sun.star.beans.XPropertySet
Public strSheetName as String = "Price"
Public strArray(,) as String={{"Aries","79"},{"Bridge","86"},{"Copper","80"}}
Public strFilePathSource as String = "file:///c:/tmp/reportcard.ods"
Sub Main
Context = uno.util.Bootstrap.bootstrap
Factory = Context.getServiceManager
Loader = CType(Factory.createInstance("com.sun.star.frame.Desktop"), unoidl.com.sun.star.frame.XComponentLoader)
Doc = Loader.loadComponentFromURL("private:factory/scalc", "_blank", 0, Nothing)
Sheets.insertNewByName(strSheetName, 0)
Sheet = DirectCast(Sheets.getByName(strSheetName).Value, unoidl.com.sun.star.sheet.XSpreadsheet)

'Insert name and grade and comments
For x = strArray.GetLowerBound(0) To strArray.GetUpperBound(0)
    For y = strArray.GetLowerBound(1) To strArray.GetUpperBound(1)
        If IsNumeric(strArray(x, y)) = True Then
           Sheet.getCellByPosition(y, x).setValue(strArray(x, y))
        Else
           Sheet.getCellByPosition(y, x).setFormula(strArray(x, y))
        End If
    Next
Next
'Insert signature

'Save
Storable = DirectCast(Doc, unoidl.com.sun.star.frame.XStorable)
FileProps.setPropertyValue("Overwrite", New uno.Any(CType(True, Boolean)))
Storable.storeAsURL(strFilePathSource, MyClass.FileProps)

If Doc IsNot Nothing Then
   Closeable = DirectCast(Doc, unoidl.com.sun.star.util.XCloseable)
   Closeable.close(True)
   Doc = Nothing
   Factory = Nothing
   Loader = Nothing
   Context = Nothing
End If

End Sub
End Class


My problem now is i don't know how to put an image to the calc document. I tried to search but i cant find anything. I'm using OpenOffice 3.3 and the following ddl: cli_basetypes,cli_cppuhelper,cli_oootypes, cli_uno,cli_ure and cli_uretypes
Tags: Visual Basic, OpenOffice, Image

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900