简体   繁体   中英

In Excel, how to show data in hidden rows and columns

This is what I have tried to do to have my chart show the data in the columns I have hidden:

Excel.Application oExcelApp = new Excel.Application;
Excel._Workbook oWB = oExcelApp.Workbooks.Add();
Excel._Worksheet oWS = oWB.ActiveSheet;

Excel.ChartObjects oCharts = (Excel.ChartObjects)oWS.ChartObjects();
Excel.ChartObject oChart = oCharts.Add(10, 80, 300, 250);
Excel.Chart chart = oChart.Chart;

// these three lines work
chart.HasTitle = true;
chart.ChartTitle.Text = "Chart Title";
chart.HasLegend = false;

// I get a compile error for this line
// because the HasHiddenContent property is read-only
chart.HasHiddenContent = true;

The HasHiddenContent property is the only one I can find that looks like it might be what I'm looking for, but it is read-only. Which property can I use to tell the chart to show data in hidden columns (and rows)?

After doing the "record the macro for what you want to do and then convert VBA to c#," I found the answer to my question.

The correct property to toggle showing data in hidden columns and rows is:

chart.PlotVisibleOnly = false;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM