Difference between revisions of "Talk:AODL example 1"

From Apache OpenOffice Wiki
Jump to: navigation, search
(At the End)
Line 35: Line 35:
 
I was only testing in simple Way this example by manipulating the Row an Column Indexis to see,
 
I was only testing in simple Way this example by manipulating the Row an Column Indexis to see,
 
if it is working. But the Result is frustrating. There is no way to put the Contens in the right Cell.
 
if it is working. But the Result is frustrating. There is no way to put the Contens in the right Cell.
 +
 +
I was able to run folowing code in vb.net
 +
 +
    'Create new spreadsheet document
 +
    Dim spreadsheetDocument As SpreadsheetDocuments.SpreadsheetDocument = New SpreadsheetDocument
 +
    spreadsheetDocument.[New]()
 +
    'Create a new table
 +
    Dim table As Table = New Table(spreadsheetDocument, "First", "tablefirst")
 +
    'Create a new cell, without any extra styles
 +
    Dim cell As Content.Tables.Cell = table.CreateCell()
 +
    'Add a paragraph to this cell
 +
    Dim paragraph As Content.Text.Paragraph = ParagraphBuilder.CreateSpreadsheetParagraph(spreadsheetDocument)
 +
    'Create some Formated text
 +
    Dim fText As New FormatedText(spreadsheetDocument, "T1", "Some Text")
 +
    'fText.TextStyle.TextProperties.Bold = "bold";
 +
    fText.TextStyle.TextProperties.Underline = LineStyles.dotted
 +
    'Add formated text
 +
    paragraph.TextContent.Add(fText)
 +
    'Add paragraph to the cell
 +
    cell.Content.Add(paragraph)
 +
    'Insert the cell at row index 2 and column index 3
 +
    'All need rows, columns and cells below the given
 +
    'indexes will be build automatically.
 +
    table.InsertCellAt(2, 3, cell)
 +
    'Insert table into the spreadsheet document
 +
    spreadsheetDocument.TableCollection.Add(table)
 +
    spreadsheetDocument.SaveTo("formated.ods")

Revision as of 15:22, 23 June 2008

I am trying to port this code to VB.NET using Visual Basic 2005 Express Edition, but I'm running into some problems.

I'll just take the first and the last code lines, trying to generate a spreadsheet document, and save it.

 Public Class Class1
   Dim _spreadsheetDocument As New AODL.Document.SpreadsheetDocuments.SpreadsheetDocument
   _spreadsheetDocument.SaveTo("formated.ods")
 End Class

The VisualBasic Editor tells me however, that it expects a declaration.

It would be nice if someone could make a Visual Basic version of the same code, that works.

Using missing

It would be nice to see which elemets I must bind by Using. So I'bind as following:

using Statement Source

 using AODL.Document.SpreadsheetDocuments;
 using AODL.Document.Collections;
 using AODL.Document.Content;
 using AODL.Document.Content.Tables;
 using AODL.Document.TextDocuments;
 using AODL.Document.Styles;
 using AODL.Document.Content.Text;

At the End of USING

I' don't know which is needed but the Compiler gives OK.

Simple Tests show Problems

I was only testing in simple Way this example by manipulating the Row an Column Indexis to see, if it is working. But the Result is frustrating. There is no way to put the Contens in the right Cell.

I was able to run folowing code in vb.net

   'Create new spreadsheet document
   Dim spreadsheetDocument As SpreadsheetDocuments.SpreadsheetDocument = New SpreadsheetDocument
   spreadsheetDocument.[New]()
   'Create a new table
   Dim table As Table = New Table(spreadsheetDocument, "First", "tablefirst")
   'Create a new cell, without any extra styles
   Dim cell As Content.Tables.Cell = table.CreateCell()
   'Add a paragraph to this cell
   Dim paragraph As Content.Text.Paragraph = ParagraphBuilder.CreateSpreadsheetParagraph(spreadsheetDocument)
   'Create some Formated text
   Dim fText As New FormatedText(spreadsheetDocument, "T1", "Some Text")
   'fText.TextStyle.TextProperties.Bold = "bold";
   fText.TextStyle.TextProperties.Underline = LineStyles.dotted
   'Add formated text
   paragraph.TextContent.Add(fText)
   'Add paragraph to the cell
   cell.Content.Add(paragraph)
   'Insert the cell at row index 2 and column index 3
   'All need rows, columns and cells below the given
   'indexes will be build automatically.
   table.InsertCellAt(2, 3, cell)
   'Insert table into the spreadsheet document
   spreadsheetDocument.TableCollection.Add(table)
   spreadsheetDocument.SaveTo("formated.ods")
Personal tools