Creating a table aspose sildes

Hello,

I need help creating a table. I used the example in the help file, but I get the following error…

BC30561: ‘Table’ is ambiguous, imported from the namespaces or types
‘System.Web.UI.WebControls, Aspose.Slides’.

I’m not sure if it has to do with the namespace?? Please add a complete example.

Here is my code.

------------------------------------------
<%@ Page Language=“VB” ContentType=“text/html” ResponseEncoding=“iso-8859-1” %>
<%@ Import Namespace=“Aspose.Slides” %>
<%
'Instantiate a Presentation object that represents a PPT file

Dim pres As Presentation = New Presentation(“ppt_template.ppt”)
'Accessing a slide using its slide position
Dim slide As Slide = pres.GetSlideByPosition(2)

'Setting table parameters
Dim xPosition As Integer = 880
Dim yPosition As Integer = 1400
Dim tableWidth As Integer = 4000
Dim tableHeight As Integer = 500
Dim columns As Integer = 4
Dim rows As Integer = 4
Dim borderWidth As Double = 2

’Adding a new table to the slide using specified table parameters
Dim table As Table=slide.Shapes.AddTable(xPosition,yPosition,tableWidth,tableHeight,columns,rows,borderWidth,Color.Blue)

'Setting the alternative text for the table that can help in future to find
’and identify this specific table
Table.AlternativeText = “myTable”

'Merging two cells
Table.MergeCells(Table.GetCell(0, 0), Table.GetCell(1, 0))
'Accessing the text frame of the first cell of the first row in the table
Dim tf As TextFrame = Table.GetCell(0, 0).TextFrame

’If text frame is not null then add some text to the cell
If tf <> Nothing Then
tf.Paragraphs(0).Portions(0).Text = "Welcome to Aspose.Slides for .NET"

End If
’Writing the presentation as a PPT file

pres.Write(“C:\modified.ppt”)

%>


Untitled Document






------------------------------------------

Thank you for your help

Dear Thierno,

Thanks for your interest in Aspose.Slides.

I have worked with the code snippet shared by you and it worked fine with me. I feel you may be missing some reference to namespace. The ambiguous namespace error usually arise when two API's have similar classes and during execution the compiler gets confuse to select which name space for the object. The resolution to such issue is to explicitly define the complete namespace with object. I have modified the code snippet for you and hopefully it will work for you.

Imports Aspose.Slides

Imports System.Web.UI.WebControls

Module Module1

Sub Main()

Dim pres As Presentation = New Presentation("ppt_template.ppt")

'Accessing a slide using its slide position

Dim slide As Slide = pres.GetSlideByPosition(2)

'Setting table parameters

Dim xPosition As Integer = 880

Dim yPosition As Integer = 1400

Dim tableWidth As Integer = 4000

Dim tableHeight As Integer = 500

Dim columns As Integer = 4

Dim rows As Integer = 4

Dim borderWidth As Double = 2

'Adding a new table to the slide using specified table parameters

Dim table As Aspose.Slides.Table = slide.Shapes.AddTable(xPosition, yPosition, tableWidth, tableHeight, columns, rows, borderWidth, System.Drawing.Color.Blue)

'Setting the alternative text for the table that can help in future to find

'and identify this specific table

table.AlternativeText = "myTable"

'Merging two cells

table.MergeCells(table.GetCell(0, 0), table.GetCell(1, 0))

'Accessing the text frame of the first cell of the first row in the table

Dim tf As TextFrame = table.GetCell(0, 0).TextFrame

'If text frame is not null then add some text to the cell

If tf <> Nothing Then

tf.Paragraphs(0).Portions(0).Text = "Welcome to Aspose.Slides for .NET"

End If

'Writing the presentation as a PPT file

pres.Write("C:\modified.ppt")

End Sub

End Module

Thanks and Regards,

Thank you for your help. That worked great.