public ExcelWriter(string filename) { template = new OoXml(filename); // Open the template sheet = template.sheets.Values.First <gSheet>(); // Get the first sheet GetMapping(); // Get the mapping sheet.SetSource(OnDataRow, fixedRows); // Set data call back, keep first row of the template }
void OnDataRow(gSheet sheet) { if (!data.Read()) { return; // If no data available then exit } sheet.BeginRow(curRow); // This is the row we are going to write foreach (KeyValuePair <int, string> m in mapping) // For each mapping value { sheet.WriteCell(m.Key, data[m.Value]); // Save it into the Excel } sheet.EndRow(); // Data has been exported curRow++; // Next record will be placed in this excel row exportedRecords++; // Increase number of exported records }
public ExcelReader(string filename) { source = new OoXml(filename); // Open the excel file sheet = source.sheets.Values.First <gSheet>(); // Get the first sheet }