Beispiel #1
0
 private void BeforeExportXLS(object sender, ExportArgs e)
 {
     OnBeforeExport(e);
 }
Beispiel #2
0
 private void ToExcel(DataTable table)
 {
     XmlDocument xml = CreateFile();
     XmlNode nodeworkbook = xml.SelectSingleNode("Workbook");
     Hashtable tableDD = GetDDTable(table);
     if (BeforeExport != null)
     {
         ExportArgs arg = new ExportArgs(table.TableName, Filter, Sort);
         BeforeExport(this, arg);
         Filter = arg.Filter;
         Sort = arg.Sort;
     }
     DataRow[] dr = table.Select(Filter, Sort);
     int maxrowcount = this.Title.Length > 0 ? 65534 : 65535;
     XmlNode nodetable = CreateWorkSheet(string.Format("{0}{1}", table.TableName, 0), nodeworkbook, table, tableDD);
     for (int i = 0; i < dr.Length; i++)
     {
         if (i != 0 && i % maxrowcount == 0)
         {
             nodetable = CreateWorkSheet(string.Format("{0}{1}", table.TableName, i / maxrowcount), nodeworkbook, table, tableDD);
         }
         XmlNode noderow = xml.CreateElement("Row");
         nodetable.AppendChild(noderow);
         foreach (DataColumn dc in table.Columns)
         {
             if (IgnoreColumns == null || !IgnoreColumns.Contains(dc.ColumnName))
             {
                 ToExcel(noderow, dr[i][dc], dc.DataType);
             }
         }
     }
     xml.Save(Excelpath);
 }
Beispiel #3
0
 protected void OnBeforeExport(ExportArgs e)
 {
     BeforeExportEventHandler handler = Events[EventBeforeExport] as BeforeExportEventHandler;
     if (handler != null)
     {
         handler(this, e);
     }
 }