File Exchange

image thumbnail

xlschart

version 1.0 (4.81 KB) by

Writes column headers and a matrix to excel and graphs all columns or two specified columns.

3 Downloads

Updated

View License

xlschart(titles,m,chartypechart_title,)
xlschart(titles,m,chartype,chart_title,filename)
xlschart(titles,m,chartype,chart_title,xtitle,ytitle)
xlschart(titles,m,chartype,chart_title,filename,sheetname)
xlschart(titles,m,chartype,chart_title,xtitle,ytitle,filename)
xlschart(titles,m,chartype,chart_title,xtitle,ytitle,filename,sheetname)

xlschart : writes column headers and a matrix to excel
and graphing all columns or 2 or more specified
columns using excel.

titles: Column titles (cell array).
m: matrix of numbers.
chartype: integer number corresponds to chart type.
chart_title: This title will be used for both chart sheet name and chart title.
filename: Name of excel file.
sheetname: sheet name.
xtitle: title of column to be x-axis (picked from titles).
ytitle: title(s) of column to be y-axis (picked from titles).

CHARTYPE:
1- ColumnClustered
2- ColumnStacked
3- ColumnStacked100
4- 3DColumnClustered
5- 3DColumnStacked
6- 3DColumnStacked100
7-3DColumn
8-BarClustered
9-BarStacked
10-BarStacked100
11-3DBarClustered
12-3DBarStacked
13-3DBarStacked100
14-Line
15-LineStacked
16-LineStacked100
17-LineMarkers
18-LineMarkersStacked
19-LineMarkersStacked100
20-3DLine
21-Pie
22-3DPie
23-PieOfPie
24-PieExploded
25-3DPieExploded
26-BarOfPie
27-XYScatter
28-XYScatterSmooth
29-XYScatterSmoothNoMarkers
30-XYScatterLines
31-XYScatterLinesNoMarkers
32-Area
33-AreaStacked
34-AreaStacked100
35-3DArea
36-3DAreaStacked
37-3DAreaStacked100
38-Doughnut
39-DoughnutExploded
40-Radar
41-RadarMarkers
42-RadarFilled
43-Surface
44-SurfaceWireframe
45-SurfaceTopView
46-SurfaceTopViewWireframe
47-Bubble
48-Bubble3DEffect
49-StockHLC
50-StockOHLC
51-StockVHLC
52-StockVOHLC

Examples:

titles = {'1st','2nd','3rd','4th','5th','6th','7th','8th','9th','10th'};
m = magic(10);
chart_title = 'My Title';
xlschart(titles,m,'LineStacked100',chart_title)
xlschart(titles,m,17,chart_title,'sample.xls','Sheet2');
xlschart(titles,m,'Line',chart_title,'1st','2nd','sample.xls','Sheet2');
xlschart(titles,m,20,chart_title,'1st','8th','sample.xls','Sheet2');
xlschart(titles,m,'XYScatterSmooth',chart_title,'10th','9th','sample.xls','Sheet2');
xlschart(titles,m,30,chart_title,'2nd',{'7th','6th'},'sample.xls','Sheet2');
xlschart(titles,m,29,chart_title,{'2nd','5th'},{'7th','6th'},'sample.xls','Sheet2');

See also XLSREAD, XLSFINFO, XLSWRITE, XLSCELL, XLSHEETS, , CPTXT2XLS, MSOPEN

Comments and Ratings (5)

Luis Cantero

I don't know if this worked with Excel 2003. I had to change the following code in order to make it work:
%%%
%Excel.ActiveChart.SeriesCollection(i).XValues = ['=' sheetname '!R2C1:R' int2str(nr+1) 'C1'];
Excel.ActiveChart.SeriesCollection(i).XValues = Excel.ActiveWorkbook.Sheets.Item(sheetname).Range(['A2:A' int2str(nr+1)]);

%Excel.ActiveChart.SeriesCollection(i).Values = ['"=' sheetname '!R2C' int2str(i+1) ':R' int2str(nr+1) 'C' int2str(i+1) '"'];
Excel.ActiveChart.SeriesCollection(i).Values = Excel.ActiveWorkbook.Sheets.Item(sheetname).Range([Excel.ActiveWorkbook.Sheets.Item(sheetname).Cells.Item(int2str(i+1)).Item(2).Address ':' Excel.ActiveWorkbook.Sheets.Item(sheetname).Cells.Item(int2str(i+1)).Item(int2str(nr+1)).Address]);
%%%

Mohammad Khalid Khan

Fantastic work!

Peng Xi

It is very enlightening -- can't believe you have done so wonderful work. I have used it in my application.
Of course, you are somewhat careless as the guy writing xlsgraph--you have common bugs. However I think it is good to leave some bug to the user, otherwise they (we) cannot learn anything from your work.
I have managed to plot the chart in the activesheet(not to open a new chart).

Beatrice Marino

error at line 243
method or property not found

Solved by changing:
Excel.ActiveChart.ChartTitle.Characters.Text = (snip)
to:
Excel.ActiveChart.ChartTitle.Text = (snip)

Paulo Goncalves

??? Invoke Error, Dispatch Exception: An attempt was made to load a program with an incorrect format.
.

Error in ==> C:\matlabR13\work\xlschart.m
On line 155 ==> sheet = get(Excel.Worksheets, 'Item', sheetname);

Updates

Chart type can be entered as string of characters

Another bug has been found and corrected

Multiple ytitles & xtitles option added + Chart Type option added

MATLAB Release
MATLAB 6.5 (R13)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video