From: Gina Stuessy on
> You cannot do this with xlswrite. However, you can do this
> by directly accessing the Excel COM server and running
> column-width and font-size VB commands on that server. The
> same applies to any other formating you may wish to do on
> the data. To see how to do this, you can edit xlswrite.m:
> It's a relatively long function, but if you ignore the
> error-checking parts, you'll see that the actual skeleton is
> pretty small.
>
> An alternative is to use the OfficeDoc submission on the
> File Exchange:
> http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=15192
>
> Yair Altman
> http://ymasoftware.com
>

Can you tell me specifically how to edit the xlswrite file to set the column widths for each column separately? (Not just 1 width that applies to the whole document.)

Thanks,
Gina
From: Andy on
% sample code

e=actxserver('excel.application');
eW=e.Workbooks;
eF=eW.Open(filename); % your filename here
eS=eF.ActiveSheet;
eS.Range('A1').EntireColumn.AutoFit; % autofit column A
eS.Range('A1').EntireColumn.Font.Name = 'Times'; % changes font to Times
From: Gina Stuessy on
"Andy " <myfakeemailaddress(a)gmail.com> wrote in message <i3havg$gkf$1(a)fred.mathworks.com>...
> % sample code
>
> e=actxserver('excel.application');
> eW=e.Workbooks;
> eF=eW.Open(filename); % your filename here
> eS=eF.ActiveSheet;
> eS.Range('A1').EntireColumn.AutoFit; % autofit column A
> eS.Range('A1').EntireColumn.Font.Name = 'Times'; % changes font to Times

I'm sorry, I was unclear. I meant I would like to save some data to an excel file through Matlab and save also the widths that the columns should be when the file is opened by someone else who has only Excel. I do not want to open the file through Matlab and then format the columns.

Thanks,
Gina
From: Andy on
"Gina Stuessy" <gstuessy(a)gmail.com> wrote in message <i3hf0q$3ve$1(a)fred.mathworks.com>...
> "Andy " <myfakeemailaddress(a)gmail.com> wrote in message <i3havg$gkf$1(a)fred.mathworks.com>...
> > % sample code
> >
> > e=actxserver('excel.application');
> > eW=e.Workbooks;
> > eF=eW.Open(filename); % your filename here
> > eS=eF.ActiveSheet;
> > eS.Range('A1').EntireColumn.AutoFit; % autofit column A
> > eS.Range('A1').EntireColumn.Font.Name = 'Times'; % changes font to Times
>
> I'm sorry, I was unclear. I meant I would like to save some data to an excel file through Matlab and save also the widths that the columns should be when the file is opened by someone else who has only Excel. I do not want to open the file through Matlab and then format the columns.
>
> Thanks,
> Gina

Right, so after writing your data with xlswrite, this code shows you exactly how to autofit the columns (and change the font if you wish) so that when somebody opens the spreadsheet later, the columns will be the correct width. I'm not sure what more you're asking for right now.
From: Gina Stuessy on
For some reason when I use that script, I get an error message saying the document is already open. If I choose to reopen it, it does have the column width set and the font changed, but then when I close the file and try to open it again, it doesn't. It appears this only works the first time it's opened.
 |  Next  |  Last
Pages: 1 2
Prev: C6416 - Missing Reply
Next: Varargin