Beispiel #1
0
        private void btExcel_Click(object sender, EventArgs e)
        {
            clsControlChargeWorkReport cls = new clsControlChargeWorkReport();

            cls.m_mthOutExcel(((clsCheckOuthistoryDay)this.objController).dtStatistics);
        }
Beispiel #2
0
        private void btExcel_Click(object sender, EventArgs e)
        {
            clsControlChargeWorkReport cls = new clsControlChargeWorkReport();
            DataRow dr = ((clsCtl_GroupWorkLoadReport)this.objController).Mydt.Rows[0];

            ((clsCtl_GroupWorkLoadReport)this.objController).Mydt.Rows[0].Delete();
            ((clsCtl_GroupWorkLoadReport)this.objController).Mydt.AcceptChanges();
            DataTable dtTempMydt = ((clsCtl_GroupWorkLoadReport)this.objController).Mydt;
            DataTable dtTemp2    = new DataTable();

            for (int i = 0; i < dtTempMydt.Columns.Count; i++)
            {
                if (dtTempMydt.Columns[i].ColumnName.IndexOf("名称") >= 0)
                {
                    dtTemp2.Columns.Add(dtTempMydt.Columns[i].ColumnName, System.Type.GetType("System.String"));
                }
                else
                {
                    dtTemp2.Columns.Add(dtTempMydt.Columns[i].ColumnName, System.Type.GetType("System.Decimal"));
                }
                //dtTemp2.Columns.Add(dtTempMydt.Columns[i].ColumnName, System.Type.GetType("System.String"));
            }
            DataRow drnew = null;

            for (int i = 0; i < dtTempMydt.Rows.Count; i++)
            {
                drnew = dtTemp2.NewRow();
                for (int i2 = 0; i2 < dtTempMydt.Columns.Count; i2++)
                {
                    if (dtTempMydt.Rows[i][i2].ToString().Trim() == "")
                    {
                        //if (dtTempMydt.Columns[i2].DataType.FullName.ToString() == "System.Decimal")
                        //{
                        //    drnew[i2] = 0;
                        //}
                        //else
                        //{
                        //    drnew[i2] = "0";
                        //}
                        drnew[i2] = "0";
                    }
                    else
                    {
                        //if (dtTempMydt.Rows[i][i2].ToString().IndexOf("合计") < 0)
                        //{
                        //    if (dtTemp2.Columns[i2].DataType.FullName.ToString() == "System.Decimal")
                        //    {
                        //        drnew[i2] = Convert.ToDecimal(dtTempMydt.Rows[i][i2]);
                        //    }
                        //    else
                        //    {
                        //        drnew[i2] = dtTempMydt.Rows[i][i2].ToString();
                        //    }
                        //}
                        drnew[i2] = dtTempMydt.Rows[i][i2];
                    }
                }
                dtTemp2.Rows.Add(drnew);
            }

            cls.m_mthOutExcel(dtTemp2);
            ((clsCtl_GroupWorkLoadReport)this.objController).Mydt.Rows.InsertAt(dr, 0);
            ((clsCtl_GroupWorkLoadReport)this.objController).Mydt.AcceptChanges();
        }