title: X-Axis label formatting issue while exporting Chart to Excel using EPPlus
body: <p>I am using EPPlus library to exporting charts from the application. But I want to change the text direction of X-Axis labels of exported graphs. I am not able to find the property in epplus. </p>
  
  <p>I have attached the image of property which I want to change in the graph using EPPLUS.</p>
  
  <p>This is code to export the graph from Dataset to excel sheet.</p>
  
  <pre><code> using (ExcelPackage objExcelPackage = new ExcelPackage())
                  {
                      int i = 0, startIndex = 1, endIndex = 1, j = 0;
                      string[] seriesValues; string[] seriesHeader;
  
                      foreach (DataTable item in ds.Tables)
                      {
                          ExcelWorksheet objWorksheet = objExcelPackage.Workbook.Worksheets.Add("Sheet" + i.ToString());
                          objWorksheet.Cells.Style.Font.SetFromFont(new System.Drawing.Font("Calibri", 10));
                          objWorksheet.Cells.AutoFitColumns();
                          dynamic chart;
  
                          //Add the chart to the sheet
                          if (item.Rows[0].CommonEnum.CommonColumnName.GraphType.ToString()].ToString() == CommonEnum.GetEnumDescription(CommonEnum.GraphType.ScatterChart) || item.Rows[0][CommonEnum.CommonColumnName.GraphType.ToString()].ToString() == CommonEnum.GraphType.ScatterChart.ToString())
                          {
                              chart = objWorksheet.Drawings.AddChart(string.Empty, eChartType.XYScatterLines);
                          }
                          else if (item.Rows[0][CommonEnum.CommonColumnName.GraphType.ToString()].ToString() == CommonEnum.GetEnumDescription(CommonEnum.GraphType.BarChart) || item.Rows[0][CommonEnum.CommonColumnName.GraphType.ToString()].ToString() == CommonEnum.GraphType.BarChart.ToString())
                          {
                              chart = objWorksheet.Drawings.AddChart(string.Empty, eChartType.ColumnClustered) as ExcelBarChart;
                          }
                          else if (item.Rows[0][CommonEnum.CommonColumnName.GraphType.ToString()].ToString() == CommonEnum.GetEnumDescription(CommonEnum.GraphType.BubbleChart) || item.Rows[0][CommonEnum.CommonColumnName.GraphType.ToString()].ToString() == CommonEnum.GraphType.BubbleChart.ToString())
                          {
                              chart = objWorksheet.Drawings.AddChart(string.Empty, eChartType.Bubble) as ExcelBubbleChart;
                          }
                          else if (item.Rows[0][CommonEnum.CommonColumnName.GraphType.ToString()].ToString() == CommonEnum.GetEnumDescription(CommonEnum.GraphType.BarSideBySideStackedSeries2D) || item.Rows[0][CommonEnum.CommonColumnName.GraphType.ToString()].ToString() == CommonEnum.GraphType.BarSideBySideStackedSeries2D.ToString())
                          {
                              chart = objWorksheet.Drawings.AddChart(string.Empty, eChartType.BarStacked) as ExcelBarChart;
                          }
                          else if (item.Rows[0][CommonEnum.CommonColumnName.GraphType.ToString()].ToString() == CommonEnum.GetEnumDescription(CommonEnum.GraphType.PointSeries2D) || item.Rows[0][CommonEnum.CommonColumnName.GraphType.ToString()].ToString() == CommonEnum.GraphType.PointSeries2D.ToString())
                          {
                              chart = objWorksheet.Drawings.AddChart(string.Empty, eChartType.XYScatter);
                          }
                          else
                          {
                              chart = objWorksheet.Drawings.AddChart(string.Empty, eChartType.Area);
                          }
  
                          if (item.TableName.Contains("TimeBased"))
                          {
                              //var chart1= objWorksheet.Drawings.AddChart(string.Empty, eChartType.XYScatter);
                              //Create the worksheet    
                              objWorksheet.Cells["A1"].LoadFromDataTable(item, true);
                              DataView view = new DataView(item);
                              DataTable distinctMeasNumber = view.ToTable(true, CommonEnum.CommonColumnName.Name.ToString());
                              objWorksheet.Column(2).Style.Numberformat.Format = "yyyy-mm-dd hh:mm:ss";
  
                              foreach (DataRow dtItemRow in distinctMeasNumber.Rows)
                              {
                                  startIndex = endIndex + 1;
                                  endIndex = GetStartEndRowCount(item, dtItemRow[CommonEnum.CommonColumnName.Name.ToString()].ToString()) + 1;
                                  chart.Series.Add(ExcelRange.GetAddress(startIndex, 3, endIndex, 3), ExcelRange.GetAddress(startIndex, 2, endIndex, 2)).Header = dtItemRow[CommonEnum.CommonColumnName.Name.ToString()].ToString();
                              }
  
  
                              chart.Title.Font.Bold = true;
                              chart.Title.Font.Size = 8;
                              chart.PlotArea.Border.LineStyle = eLineStyle.Solid;
                              chart.SetSize(650, 320);
                              chart.XAxis.MajorTickMark = eAxisTickMark.Cross;
                              chart.XAxis.MinorTickMark = eAxisTickMark.Cross;
                              chart.XAxis.LabelPosition = eTickLabelPosition.Low;
                              chart.YAxis.LabelPosition = eTickLabelPosition.Low;
  
                              chart.YAxis.MajorTickMark = eAxisTickMark.None;
                              chart.YAxis.MinorTickMark = eAxisTickMark.None;
                              chart.XAxis.Title.Text = item.Columns[1].ColumnName;`enter code here`
                              chart.XAxis.Title.Font.Size = 8;
                              chart.YAxis.Title.Text = item.Columns[2].ColumnName;
                              chart.YAxis.Title.Font.Size = 8;
                              i++;
                          }                      
                              chart.Title.Font.Bold = true;
                              chart.Title.Font.Size = 8;
                              chart.PlotArea.Border.LineStyle = eLineStyle.Solid;
                              chart.SetSize(580, 300);
                              chart.XAxis.MajorTickMark = eAxisTickMark.None;
                              chart.XAxis.MinorTickMark = eAxisTickMark.None;
                              chart.XAxis.LabelPosition = eTickLabelPosition.Low;
                              chart.YAxis.LabelPosition = eTickLabelPosition.Low;
  
                              chart.YAxis.MajorTickMark = eAxisTickMark.None;
                              chart.YAxis.MinorTickMark = eAxisTickMark.None;
  
                              chart.XAxis.Title.Text = item.Rows[0][CommonEnum.CommonColumnName.Col1Value.ToString()].ToString();
                              chart.XAxis.Title.Font.Size = 8;
                              chart.YAxis.Title.Text = item.Rows[0][CommonEnum.CommonColumnName.Col2Value.ToString()].ToString();
                              chart.YAxis.Title.Font.Size = 8;
                          }
  
                          chart.SetPosition(4, 0, 7, 0);
  
                          chart.Style = eChartStyle.Style2;
                      }
  
                       if (File.Exists(saveAsLocation))
                         File.Delete(saveAsLocation);
  
                      //Create excel file on physical disk    
                      FileStream objFileStrm = File.Create(saveAsLocation);
                      objFileStrm.Close();
  
                      //Write content to excel file    
                      File.WriteAllBytes(saveAsLocation, objExcelPackage.GetAsByteArray());
                  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/JsKBt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JsKBt.png" alt="enter image description here"></a></p>