public static List <string []> ReadExcel() { List <string []> dataStrings = new List <string []>(); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Execl files (*.xlsx)|*.xlsx"; openFileDialog.FilterIndex = 0; openFileDialog.RestoreDirectory = true; openFileDialog.Title = "Import Excel File"; if (openFileDialog.ShowDialog() == DialogResult.OK) { clsGeneral cls = new clsGeneral(); DataTable data = cls.ReadExcel2007(openFileDialog.FileName, true); if (data == null) { return(null); } foreach (DataRow row in data.Rows) { dataStrings.Add(row.ItemArray.OfType <string>().ToArray()); } } else { return(null); } return(dataStrings); }
public static void CreateExcel(List <string> names, List <List <string> > projectdata, int n, string name) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Execl files (*.xlsx)|*.xlsx"; saveFileDialog.FilterIndex = 0; saveFileDialog.RestoreDirectory = true; saveFileDialog.CreatePrompt = true; saveFileDialog.Title = "Export Excel File To"; DataSet data = CreateDataset(names, projectdata, name); if (saveFileDialog.ShowDialog() == DialogResult.OK) { clsGeneral cls = new clsGeneral(); cls.GenerateExcel2007(saveFileDialog.FileName, data, n); } }