Error while selecting range for Excel chart using Matlab
I have an Excel file with sheets. First, about 30 columns and 20,000 rows. 2 about 10 columns and 2 rows. Each with a headline.
No, the file I am working in has less than 66,000 lines and I am using .xlsx files so this is not a problem. this one could be related but didn't help me
The targets for the script were:
- Automatic creation of a diagram in an already existing file
.xlsx
using Matlab - Easy way to select Range, X- and Y-values ββ(by sheet and column) freely
- applicable to all sizes in files
.xlsx
. (up to 20,000 rows and 50 columns and multiple sheets).
In this range, Code is set to: X -> column B, Y -> column H - P, sheet - "sheet1" called "Tabelle1"
%%%%% general Code to insert a Chart in Excel using Matlab %%%%% %% start Excel and open Workbook excel = actxserver('Excel.Application'); wb = excel.Workbooks.Open('C:\...\Test.xlsx'); %% makes the created sheet visible excel.Visible = true; %% add 1. Chart chart1 = wb.Charts.Add; %% set source data chart1.SetSourceData(wb.Worksheets.Item('Tabelle1').Range('$B:$B, $H:$P')); % 'Tabelle1' is the german equal to sheet1, my excel is german %% Name chart sheet chart1.Name = '1. TestChart'; %% Set chart title, see https://msdn.microsoft.com/en-us/library/office/ff196832.aspx chart1.HasTitle = true; chart1.ChartTitle.Text = 'Test Title'; %% Set chart types, see https://msdn.microsoft.com/en-us/library/office/ff837417.aspx chart1.ChartType = 'xlXYScatterSmoothNoMarkers'; %% Set chart legend, see https://msdn.microsoft.com/en-us/library/office/ff821884.aspx chart1.HasLegend = true; %% Set Axes Titles chart1.Axes(1).HasTitle = true; chart1.Axes(1).AxisTitle.Text = 'Time [s]'; % XAxes chart1.Axes(2).HasTitle = true; chart1.Axes(2).AxisTitle.Text = 'Temperature[Β°C]'; %YAxes %% add 2nd chart chart2 = wb.Charts.Add([], chart1); %place after chart1 chart2.SetSourceData(wb.Worksheets.Item('Tabelle1').Range('$B:$B, $Q:$Q')); % ... same procedure as above %% use to quit all open Excel processes % excel.Quit;
this error occurs:
Error using interface .000208D8_0000_0000_C000_000000000046 / Range
Error: Object returned error code: 0x800A03EC
Error in CodeTestmy (line 13) chart1.SetSourceData (wb.Worksheets.Item ('Tabelle1'). Range ('$ B: $ B, $ H: $ P'));
I'm sure this code is working perfectly and I can't explain the error.
Could you please help me to find out if there were errors in order to finally solve the problem.
Here links (Google Drive) to .m script
and.xlsx file
thank
Kilian Weber
source to share
No one has answered this question yet
See similar questions:
or similar: