public static void Main(string[] args) { Console.WriteLine("Hello World!"); // TODO: Implement Functionality Here //adaptor.OpenExisting(@"C:\Test Excel\Book1.xlsx"); var data = new List <double>(); data.Add(10); data.Add(10); data.Add(10); data.Add(10); data.Add(10); var data2 = new List <string>(); data2.Add("hello"); data2.Add("hello"); data2.Add("hello"); data2.Add("hello"); data2.Add("hello"); data2.Add("hello"); data2.Add("hello"); data2.Add("hello"); data2.Add("hello"); data2.Add("hello"); data2.Add("hello"); data2.Add("hello"); data2.Add("hello"); var adaptor = new ExcelWorkBookAdaptor(); adaptor.NewBook(); var listAdapter = new ListToExcelTableAdaptor <string>(adaptor[0], data2); listAdapter.Write(new ExcelCellCoordinate(10, 10), 2); var format = new ExcelRangeTableStyle(adaptor[0], new ExcelCellCoordinate(10, 10), new ExcelCellCoordinate(15, 15)) { FirstRowContainHeaders = true }; format.Execute(); adaptor.Show(); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); adaptor.SaveAndClose(@"C:\Test Excel\Book2.xlsx"); }
private void ExportResultsToExcel <T>(ExcelWorkBookAdaptor wbk, List <T> results, ExcelCellCoordinate coord) { var pipe = new ObjectPropertiesToExcelAdapter <T>(wbk[0], results); pipe.Write(coord); ExcelCellCoordinate bottomRight = new ExcelCellCoordinate(coord.Row + results.Count, coord.Col + PropertyCount(results) - 1); ExcelRangeTableStyle style = new ExcelRangeTableStyle(wbk[0], coord, bottomRight) { FirstRowContainHeaders = true }; style.Execute(); }
private void button1_Click(object sender, EventArgs e) { var adaptor = new ExcelWorkBookAdaptor(); adaptor.NewBook(); Point topLeft = new Point(1, 1); Point bottomRight = new Point(this.grid.ScenarioData.Columns.Count, this.grid.ScenarioData.Rows.Count + 1); var tableAdapter = new DataTableToExcelAdapter(adaptor[0], this.grid.ScenarioData); tableAdapter.Write(topLeft); var format = new ExcelRangeTableStyle(adaptor[0], topLeft, bottomRight) { FirstRowContainHeaders = true }; format.Execute(); adaptor.Show(); }