How to delete a spreadsheet

S

stocki

Hi,

still working on my spreadsheet app. Got an owc spreadsheet (OWC11) on
a windows form. This control does have three sheets. I want to delete
two of them using C#.

axSpreadsheet1.Worksheets["Sheet1"].delete() ; throws an error,
telling me that this object doesn't contain a definition for
"delete".

Anyone an idea, please?

Thanks for your help!

Cheers

Stocki
 
S

stocki

Try

axSpreadsheet1.Sheets(1).delete()

josh


still working on my spreadsheet app. Got an owc spreadsheet (OWC11) on
a windows form. This control does have three sheets. I want to delete
two of them using C#.
axSpreadsheet1.Worksheets["Sheet1"].delete() ; throws an error,
telling me that this object doesn't contain a definition for
"delete".
Anyone an idea, please?
Thanks for your help!

Stocki

Hi Josh,

doesn't work, cause you have to use square brackets "[" instead of
normal brackets "(" after the sheets collection. If I do so, I get the
same result like using "Worksheets" ...

Cheers

Stocki
 
J

Josh Sale

I don't know what you mean about having to use square brackets. In my code
I use parens as I showed in my example and it works fine.
 
S

stocki

I don't know what you mean about having to use square brackets. In my code
I use parens as I showed in my example and it works fine.
doesn't work, cause you have to use square brackets "[" instead of
normal brackets "(" after the sheets collection. If I do so, I get the
same result like using "Worksheets" ...

Stocki

Hi Josh,
if I paste your command into my code I get an error
"AxMicrosoft.Office.Interop.Owc11.AxSpreadsheet.Sheets is a property
but it is used as a method" (translation into english) ...

How ist your "axSpreadsheet1" defined?

Cheers

Stocki
 
J

Josh Sale

Here it is right out of my code:

Dim i As Integer

Dim oViewSS As OWC.Spreadsheet

oViewSS.Sheets(i).delete()





stocki said:
I don't know what you mean about having to use square brackets. In my
code
I use parens as I showed in my example and it works fine.
doesn't work, cause you have to use square brackets "[" instead of
normal brackets "(" after the sheets collection. If I do so, I get the
same result like using "Worksheets" ...

Stocki

Hi Josh,
if I paste your command into my code I get an error
"AxMicrosoft.Office.Interop.Owc11.AxSpreadsheet.Sheets is a property
but it is used as a method" (translation into english) ...

How ist your "axSpreadsheet1" defined?

Cheers

Stocki
 
S

stocki

Here it is right out of my code:

Dim i As Integer

Dim oViewSS As OWC.Spreadsheet

oViewSS.Sheets(i).delete()




I don't know what you mean about having to use square brackets. In my
code
I use parens as I showed in my example and it works fine.
Hi Josh,
doesn't work, cause you have to use square brackets "[" instead of
normal brackets "(" after the sheets collection. If I do so, I get the
same result like using "Worksheets" ...
Cheers
Stocki
Hi Josh,
if I paste your command into my code I get an error
"AxMicrosoft.Office.Interop.Owc11.AxSpreadsheet.Sheets is a property
but it is used as a method" (translation into english) ...
How ist your "axSpreadsheet1" defined?

Stocki- Zitierten Text ausblenden -

- Zitierten Text anzeigen -

.... I see, you are talking VB.Net not C# ... how is your
"OWC.Spreadsheet" defined? I put you piece of code into a small VB App
and the IDE stumbles across the line "Dim oViewSS As OWC.Spreadsheet
". So it is not enough to place the spreadsheet control on a form ..

Sorry to be pain!

Stocki
 
J

Josh Sale

First, I'm doing my processing server side.

Second, you would need this statement at the top of your module:

Imports OWC = Microsoft.Office.Interop.Owc11

And then a statement like:

oViewSS = New OWC.Spreadsheet

before you try to do the Delete.

josh





stocki said:
Here it is right out of my code:

Dim i As Integer

Dim oViewSS As OWC.Spreadsheet

oViewSS.Sheets(i).delete()




I don't know what you mean about having to use square brackets. In my
code
I use parens as I showed in my example and it works fine.
doesn't work, cause you have to use square brackets "[" instead of
normal brackets "(" after the sheets collection. If I do so, I get
the
same result like using "Worksheets" ...

Hi Josh,
if I paste your command into my code I get an error
"AxMicrosoft.Office.Interop.Owc11.AxSpreadsheet.Sheets is a property
but it is used as a method" (translation into english) ...
How ist your "axSpreadsheet1" defined?

Stocki- Zitierten Text ausblenden -

- Zitierten Text anzeigen -

... I see, you are talking VB.Net not C# ... how is your
"OWC.Spreadsheet" defined? I put you piece of code into a small VB App
and the IDE stumbles across the line "Dim oViewSS As OWC.Spreadsheet
". So it is not enough to place the spreadsheet control on a form ..

Sorry to be pain!

Stocki
 
S

stocki

First, I'm doing my processing server side.

Second, you would need this statement at the top of your module:

Imports OWC = Microsoft.Office.Interop.Owc11

And then a statement like:

oViewSS = New OWC.Spreadsheet

before you try to do the Delete.

josh




Here it is right out of my code:
Dim i As Integer
Dim oViewSS As OWC.Spreadsheet
oViewSS.Sheets(i).delete()

I don't know what you mean about having to use square brackets. In my
code
I use parens as I showed in my example and it works fine.
Hi Josh,
doesn't work, cause you have to use square brackets "[" instead of
normal brackets "(" after the sheets collection. If I do so, I get
the
same result like using "Worksheets" ...
Cheers
Stocki
Hi Josh,
if I paste your command into my code I get an error
"AxMicrosoft.Office.Interop.Owc11.AxSpreadsheet.Sheets is a property
but it is used as a method" (translation into english) ...
How ist your "axSpreadsheet1" defined?
Cheers
Stocki- Zitierten Text ausblenden -
- Zitierten Text anzeigen -
... I see, you are talking VB.Net not C# ... how is your
"OWC.Spreadsheet" defined? I put you piece of code into a small VB App
and the IDE stumbles across the line "Dim oViewSS As OWC.Spreadsheet
". So it is not enough to place the spreadsheet control on a form ..
Sorry to be pain!
Stocki- Zitierten Text ausblenden -

- Zitierten Text anzeigen -

Hi Josh,

your code works brilliant! It is quite interesting to see, that the
dynamically created spreadsheet allows xxx.Sheets(2).Delete(), while
working "directly" with the control this line creates an error.
Workaround would be to select the respective sheet first and do a
xxx.ActiceSheet.Delete() afterwards ...

You never stop learning, do you?

Thanks for all your support!

Cheers

Stocki
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top