I have written a script which looks in a directory, calls up appropriate files, and analyzes them all one at a time with a for loop. It takes data from an excel file, manipulates it, and saves it to a new excel file. I need an excel plot as well as the data in the new excel file... is there a way to have excel create a plot through MATLAB? I know I can send a MATLAB plot to excel with xlswritefig, but that's not exactly what I'm going for. Any ideas? Thanks

0 |

7/15/2010 6:20:10 PM

"Morgan Fox" <mdf8@duke.edu> wrote in message <i1njgq$1og$1@fred.mathworks.com>... > I have written a script which looks in a directory, calls up appropriate files, and analyzes them all one at a time with a for loop. It takes data from an excel file, manipulates it, and saves it to a new excel file. I need an excel plot as well as the data in the new excel file... is there a way to have excel create a plot through MATLAB? I know I can send a MATLAB plot to excel with xlswritefig, but that's not exactly what I'm going for. > > Any ideas? > > Thanks You can use actxserver to have very fine control of Excel documents in MATLAB. Here is some sample code to get you started, but you should spend lots of time reading the documentation and exploring the Excel objects. %% e = actxserver('excel.application'); eWs = e.Workbooks; eW = eWs.Add; eS = eW.ActiveSheet; e.Visible = 1; %% x=sin(1:100)'; eS.Range('A1:A100').Value = x; %% eCO = eS.ChartObjects.Add(100, 30, 400, 250); eCO.Chart.ChartWizard(eS.Range('A1:A100')); eCO.Chart.ChartType = 1; % view the chart before moving on %% eCO.Chart.ChartType = 65; % view it again %% eCO.Chart.HasTitle = true; eCO.Chart.ChartTitle.Text = 'This is the title text'; % view it again %% eW.Close; e.Quit; delete(e)

0 |

7/15/2010 7:26:20 PM

Andy, I think that will work. I appreciate it.

0 |

7/15/2010 7:43:04 PM

% Apologies for my previous post. The following is better: %% e = actxserver('excel.application'); eWs = e.Workbooks; eW = eWs.Add; eS = eW.ActiveSheet; e.Visible = 1; %% x=(0:2:100)'; y=sin(x); eS.Range('A1:B50').Value = [x y]; %% eCO = eS.ChartObjects.Add(100, 30, 400, 250); eC = eCO.Chart; eC.SeriesCollection.NewSeries; % better control of the data if the line number % is not your x-axis eC.SeriesCollection(1).Value = eS.Range('B1:B50'); eC.SeriesCollection(1).XValue = eS.Range('A1:A50'); %% eCO.Chart.ChartType = 1; % view the chart before moving on %% eCO.Chart.ChartType = 65; % view it again %% eCO.Chart.HasTitle = true; eCO.Chart.ChartTitle.Text = 'This is the title text'; % view it again %% eW.Close; e.Quit; delete(e)

0 |

7/15/2010 8:03:40 PM

"Andy" wrote in message <i1nncr$dts$1@fred.mathworks.com>... > "Morgan Fox" <mdf8@duke.edu> wrote in message <i1njgq$1og$1@fred.mathworks.com>... > > I have written a script which looks in a directory, calls up appropriate files, and analyzes them all one at a time with a for loop. It takes data from an excel file, manipulates it, and saves it to a new excel file. I need an excel plot as well as the data in the new excel file... is there a way to have excel create a plot through MATLAB? I know I can send a MATLAB plot to excel with xlswritefig, but that's not exactly what I'm going for. > > > > Any ideas? > > > > Thanks > > You can use actxserver to have very fine control of Excel documents in MATLAB. Here is some sample code to get you started, but you should spend lots of time reading the documentation and exploring the Excel objects. > > > > %% > > e = actxserver('excel.application'); > eWs = e.Workbooks; > eW = eWs.Add; > eS = eW.ActiveSheet; > e.Visible = 1; > > %% > > x=sin(1:100)'; > eS.Range('A1:A100').Value = x; > > %% > > eCO = eS.ChartObjects.Add(100, 30, 400, 250); > eCO.Chart.ChartWizard(eS.Range('A1:A100')); > eCO.Chart.ChartType = 1; % view the chart before moving on > > %% > > eCO.Chart.ChartType = 65; % view it again > > %% > > eCO.Chart.HasTitle = true; > eCO.Chart.ChartTitle.Text = 'This is the title text'; % view it again > > %% > > eW.Close; > e.Quit; > delete(e) Hello! Do you know how to open an existing excel file and add both the chart and the data to the same sheet number? Everything I have tried adds the chart to a new sheet. And it seems to be ignoring the active sheet.

0 |

6/30/2016 11:16:04 PM

"M275" wrote in message <nl497k$5kk$1@newscl01ah.mathworks.com>... > "Andy" wrote in message <i1nncr$dts$1@fred.mathworks.com>... > > "Morgan Fox" <mdf8@duke.edu> wrote in message <i1njgq$1og$1@fred.mathworks.com>... > > > I have written a script which looks in a directory, calls up appropriate files, and analyzes them all one at a time with a for loop. It takes data from an excel file, manipulates it, and saves it to a new excel file. I need an excel plot as well as the data in the new excel file... is there a way to have excel create a plot through MATLAB? I know I can send a MATLAB plot to excel with xlswritefig, but that's not exactly what I'm going for. > > > > > > Any ideas? > > > > > > Thanks > > > > You can use actxserver to have very fine control of Excel documents in MATLAB. Here is some sample code to get you started, but you should spend lots of time reading the documentation and exploring the Excel objects. > > > > > > > > %% > > > > e = actxserver('excel.application'); > > eWs = e.Workbooks; > > eW = eWs.Add; > > eS = eW.ActiveSheet; > > e.Visible = 1; > > > > %% > > > > x=sin(1:100)'; > > eS.Range('A1:A100').Value = x; > > > > %% > > > > eCO = eS.ChartObjects.Add(100, 30, 400, 250); > > eCO.Chart.ChartWizard(eS.Range('A1:A100')); > > eCO.Chart.ChartType = 1; % view the chart before moving on > > > > %% > > > > eCO.Chart.ChartType = 65; % view it again > > > > %% > > > > eCO.Chart.HasTitle = true; > > eCO.Chart.ChartTitle.Text = 'This is the title text'; % view it again > > > > %% > > > > eW.Close; > > e.Quit; > > delete(e) > > > Hello! Do you know how to open an existing excel file and add both the chart and the data to the same sheet number? Everything I have tried adds the chart to a new sheet. And it seems to be ignoring the active sheet. M275 I had the same problem

0 |

10/6/2016 1:41:03 PM

"M275" wrote in message <nl497k$5kk$1@newscl01ah.mathworks.com>... > "Andy" wrote in message <i1nncr$dts$1@fred.mathworks.com>... > > "Morgan Fox" <mdf8@duke.edu> wrote in message <i1njgq$1og$1@fred.mathworks.com>... > > > I have written a script which looks in a directory, calls up appropriate files, and analyzes them all one at a time with a for loop. It takes data from an excel file, manipulates it, and saves it to a new excel file. I need an excel plot as well as the data in the new excel file... is there a way to have excel create a plot through MATLAB? I know I can send a MATLAB plot to excel with xlswritefig, but that's not exactly what I'm going for. > > > > > > Any ideas? > > > > > > Thanks > > > > You can use actxserver to have very fine control of Excel documents in MATLAB. Here is some sample code to get you started, but you should spend lots of time reading the documentation and exploring the Excel objects. > > > > > > > > %% > > > > e = actxserver('excel.application'); > > eWs = e.Workbooks; > > eW = eWs.Add; > > eS = eW.ActiveSheet; > > e.Visible = 1; > > > > %% > > > > x=sin(1:100)'; > > eS.Range('A1:A100').Value = x; > > > > %% > > > > eCO = eS.ChartObjects.Add(100, 30, 400, 250); > > eCO.Chart.ChartWizard(eS.Range('A1:A100')); > > eCO.Chart.ChartType = 1; % view the chart before moving on > > > > %% > > > > eCO.Chart.ChartType = 65; % view it again > > > > %% > > > > eCO.Chart.HasTitle = true; > > eCO.Chart.ChartTitle.Text = 'This is the title text'; % view it again > > > > %% > > > > eW.Close; > > e.Quit; > > delete(e) > > > Hello! Do you know how to open an existing excel file and add both the chart and the data to the same sheet number? Everything I have tried adds the chart to a new sheet. And it seems to be ignoring the active sheet. M275 I had the same problem. You simply slide over %eW = eWs.Add; and transform eS = eW.ActiveSheet; to eS = eWs.ActiveSheet;

0 |

10/6/2016 1:43:03 PM