using System; using System.Collections.Generic; using System.Text; using Docs.Excel; namespace TextAlign { class Program { static void Main(string[] args) { //Create a new workbook. ExcelWorkbook Wbook = new ExcelWorkbook(); //Add new worksheet to workbook. Wbook.Worksheets.Add("Sheet1"); Wbook.Worksheets[0].Columns[1].Width = 80; Wbook.Worksheets[0].Cells[0, 1].Value = "Text align"; Wbook.Worksheets[0].Cells[2, 1].Value = "Left"; Wbook.Worksheets[0].Cells[2, 1].Style.HorizontalAlignment = TypeOfHAlignment.Left; Wbook.Worksheets[0].Cells[3, 1].Value = "Center"; Wbook.Worksheets[0].Cells[3, 1].Style.HorizontalAlignment = TypeOfHAlignment.Center; Wbook.Worksheets[0].Cells[4, 1].Value = "Right"; Wbook.Worksheets[0].Cells[4, 1].Style.HorizontalAlignment = TypeOfHAlignment.Right; Wbook.Worksheets[0].Rows[5].Height = 35; Wbook.Worksheets[0].Cells[5, 1].Value = "Top"; Wbook.Worksheets[0].Cells[5, 1].Style.VerticalAlignment = TypeOfVAlignment.Top; Wbook.Worksheets[0].Rows[6].Height = 35; Wbook.Worksheets[0].Cells[6, 1].Value = "Center"; Wbook.Worksheets[0].Cells[6, 1].Style.VerticalAlignment = TypeOfVAlignment.Center; Wbook.Worksheets[0].Rows[7].Height = 35; Wbook.Worksheets[0].Cells[7, 1].Value = "Bottom"; Wbook.Worksheets[0].Cells[7, 1].Style.VerticalAlignment = TypeOfVAlignment.Bottom; Wbook.Worksheets[0].Rows[8].Height = 65; Wbook.Worksheets[0].Cells[8, 1].Value = "Rotation 45"; Wbook.Worksheets[0].Cells[8, 1].Style.VerticalAlignment = TypeOfVAlignment.Center; Wbook.Worksheets[0].Cells[8, 1].Style.Rotation = 45; Wbook.Worksheets[0].Rows[9].Height = 206; Wbook.Worksheets[0].Cells[9, 1].Value = "Rotation 255"; Wbook.Worksheets[0].Cells[9, 1].Style.VerticalAlignment = TypeOfVAlignment.Center; Wbook.Worksheets[0].Cells[9, 1].Style.Rotation = 255; //Write .xls file. Wbook.WriteXLS(@"..\..\..\TextAlignment.xls"); //Write .xlsx file. Wbook.WriteXLSX(@"..\..\..\TextAlignment.xlsx"); //Open specified file in MS Excel. System.Diagnostics.Process.Start(@"..\..\..\TextAlignment.xlsx"); } } }