How to change an excel chart axis text orientation in VB.Net?
Hi, I am developing a VB.Net application that will populate data from database to excel and create an excel chart base on the data. I already got excel data and chart, but I need to change one axis text orientation to 45 degree. How can I do that in VB code? Thanks for the help!
Re: How to change an excel chart axis alignmen in VB.Net?
You need to reference the Microsoft.Office.Core namespace, ie.
.ReadingOrder = Microsoft.Office.Core.XlReadingOrder.xlContext
Re: How to change an excel chart axis alignmen in VB.Net?
Change category label text on the worksheet
On the worksheet, click the cell that contains the name of the label that you want to change.
Type the new name, and then press ENTER.
Note Changes that you make on the worksheet are automatically updated in the chart.
Change the label text in the chart
In the chart, click the horizontal axis, or do the following to select the axis from a list of chart elements:
Click anywhere in the chart.
This displays the Chart Tools, adding the Design and Format tabs.
On the Format tab, in the Current Selection group, click the arrow in the Chart Elements box, and then click the horizontal (category) axis.
On the Design tab, in the Data group, click Select Data.
In the Select Data Source dialog box, under Horizontal (Categories) Axis Labels, click Edit.
In the Axis label range box, do one of the following:
Specify the worksheet range that you want to use as category axis labels.
Type the labels that you want to use, separated by commas — for example, Division A, Division B, Division C.
Click OK.
I hope this information will be helpful!
Tim Paine