Delete sheet excel

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Delete sheet excel

turbofib
hi,
i use  xlswrite(namefile…) to rewrite in the Excel file

but i don't know if it's possible to delete the old sheet in this file..

thank




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Delete sheet excel

Colin Macdonald-2
On 2018-07-03 07:46 AM, turbofib wrote:
> i use  xlswrite(namefile…) to rewrite in the Excel file
>
> but i don't know if it's possible to delete the old sheet in this file..

Does "help unlink" do what you want?

Colin


Reply | Threaded
Open this post in threaded view
|

Re: Delete sheet excel

turbofib
no

example:

Name file Excel : "prova:xls"

Name sheet in this file : "workgroup"

i don't want to delete "prova.xls" but i want to delete "workgroup"




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Delete sheet excel

Colin Macdonald-2
On 2018-07-03 10:51 AM, turbofib wrote:
> no
>
> example:
>
> Name file Excel : "prova:xls"
>
> Name sheet in this file : "workgroup"
>
> i don't want to delete "prova.xls" but i want to delete "workgroup"

Got it.  Sorry that goes well beyond my comfort level with the octave-io
package, hopefully someone else has an idea.

Colin



Reply | Threaded
Open this post in threaded view
|

Re: Delete sheet excel

LucaLuca

Hello,
I'm pure I'm interested in cleaning only the excel sheet (but not the file)

Who can help me?



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Delete sheet excel

PhilipNienhuis
In reply to this post by turbofib
turbofib wrote
> hi,
> i use  xlswrite(namefile…) to rewrite in the Excel file
>
> but i don't know if it's possible to delete the old sheet in this file..

Why do you need this in the first place?
You can simply overwrite data in existing worksheets. If existing data are
in the way it may well be (I'm not sure) that writing a big enough numeric
array of NaNs will wipe existing spreadsheet data in the written-to cell
range.

Anyway, removing a worksheet is certainly possible but you need to dive into
the relevant Javadocs for each Java-based interface and/or into Visual Basic
for the COM interface (when using the windows package and Excel).
For the latter case have a look at private/__COM_oct2spsh__.m, lines
182-186, in the io package.
For the Java-based interfaces you have to dive in the docs for Apache POI,
JOD, etc. yourself.

Philip




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Delete sheet excel

LucaLuca
it's correct...

the problem is   the new dimension matrix is different

But is more larger o smaller?


I should record on file the size of the old matrix
 



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Delete sheet excel

PhilipNienhuis
LucaLuca wrote
> it's correct...
>
> the problem is   the new dimension matrix is different
>
> But is more larger o smaller?
>
>
> I should record on file the size of the old matrix

Using the function xlsfinfo() on the spreadsheet file you get the dimensions
of the rectangle containing all data cells for each worksheet (note: Matlab
doesn't do this, Octave's xlsfinfo is a bit better in this respect).
So you can use xlsfinfo's output to create a large enough NaN array to wipe
all data in a certain sheet. (I just tried and writing NaNs will indeed
erase data in the referenced spreadsheet cells).
Or write a NaN array tojust the cll ranges you want to be wiped.
Or you can make an array (or cell array) with new data and augment it with
NaN cells to wipe data you don't want to retain.
So, lots and lots of ways to do it.
Just experiment a bit ....

Philip




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html