小弟一直搞web开发,现在急做一个winform操作分析excel数据的小程序,只有几天的时限。excel简单的导入导出之前到是接触过,可windows application一直没搞过,谁有winform的例子,请分享一下,有操作excel的代码也好。
[email protected]

解决方案 »

  1.   

    http://www.qqview.com/Dev/DotNet/200711317338.Html
      

  2.   

    http://www.qqview.com/Dev/DotNet/200782115901.Html
      

  3.   

    http://www.qqview.com/Dev/DotNet/200742812806.Html
      

  4.   

    cs 程序比web还简单的
    排版窗体想怎么放就怎么放
      

  5.   

    怎么就没人再给下载地址了呢,谁能给个c/s的源码呀。简单的mis的就好呀,真不甘心就这样的结贴了
      

  6.   

    string path = Application.StartupPath + "\\" + "temp";
                string sfilename = Application.StartupPath + "\\" + "temp" + "\\PrintXsSytj.xls";            try
                {
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    if (File.Exists(sfilename))
                    {
                        File.Delete(sfilename);
                    }
                    Stream dataFileStream = Erm.ShareManagement.ApplicationManagement.GetResourceStream("Erm.Resources.Excel.PrintXsSytj.xls");                byte[] Content = new byte[(int)dataFileStream.Length];
                    //将文件内容写入字节数组                dataFileStream.Read(Content, 0, Content.Length);
                    //关闭文件流
                    dataFileStream.Close();                FileStream fs = new FileStream(sfilename, FileMode.CreateNew);                fs.Write(Content, 0, Content.Length);
                    fs.Close();                Excel.Application excel = new Excel.Application();
                    object oMissing = System.Reflection.Missing.Value;
                    excel.Application.Workbooks.Open(sfilename, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
                    Excel.Workbook mybook = (Excel.Workbook)excel.ActiveWorkbook;
                    Excel.Worksheet mysheet = (Excel.Worksheet)mybook.ActiveSheet;
                    if (gridex.RowCount < 1)
                    {
                        return;
                    }
                    Double xj = 0;
                    Double yb = 0;
                    Double yl = 0;
                    Double djq = 0;
                    Double ys = 0;
                    Double ss = 0;                foreach (GridEXRow myrow in gridex.GetRows())
                    {
                        try
                        {
                            if (myrow.RowType == RowType.GroupFooter)
                            {
                                return;
                            }                        //选中格式化好的行
                            Excel.Range range = (Excel.Range)mysheet.Rows.get_Item(3, Type.Missing);
                            range.Rows.Insert(Excel.XlInsertShiftDirection.xlShiftDown);
                            //range.Rows.Insert(Excel.XlInsertShiftDirection.xlShiftToRight);                        //在第3行上插入一行,新插入的则始终为第3行                        excel.Cells[3, 2] = myrow.Cells["柜组名称"].Value.ToString();
                            excel.Cells[3, 3] = myrow.Cells["现金"].Value.ToString();
                            excel.Cells[3, 4] = myrow.Cells["医保"].Value.ToString();
                            excel.Cells[3, 5] = myrow.Cells["银联"].Value.ToString();
                            excel.Cells[3, 6] = myrow.Cells["代金券"].Value.ToString();
                            excel.Cells[3, 7] = myrow.Cells["应收"].Value.ToString();
                            excel.Cells[3, 8] = myrow.Cells["实收"].Value.ToString();
                            xj += Convert.ToDouble(myrow.Cells["现金"].Value);
                            yb += Convert.ToDouble(myrow.Cells["医保"].Value);
                            yl += Convert.ToDouble(myrow.Cells["银联"].Value);
                            djq += Convert.ToDouble(myrow.Cells["代金券"].Value);
                            ys += Convert.ToDouble(myrow.Cells["应收"].Value);
                            ss += Convert.ToDouble(myrow.Cells["实收"].Value);                    }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                            excel.Quit();
                        }                }                //开始日期
                    excel.Cells.Replace("{#SDATE#}", Sdate.ToString("yyyy年MM月dd日HH点mm分"), Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    //结束日期
                    excel.Cells.Replace("{#EDATE#}", Edate.ToString("yyyy年MM月dd日HH点mm分"), Type.Missing, Type.Missing, Type.Missing, Type.Missing);                //汇总信息
                    excel.Cells.Replace("{#XJ#}", xj, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    excel.Cells.Replace("{#YB#}", yb, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    excel.Cells.Replace("{#YL#}", yl, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    excel.Cells.Replace("{#DJQ#}", djq, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    excel.Cells.Replace("{#YS#}", ys, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    excel.Cells.Replace("{#SS#}", ss, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    excel.Cells.Replace("{#FLWJ#}", flwj, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    //预览后打印
                    excel.Visible = true;
                    mybook.PrintPreview(1);                //单据调整好后,不用预览直接打印,打印后直接退出
                    //mybook.PrintOut(Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); 
                    //mybook.Close(0, Type.Missing, Type.Missing);
                    //excel.Quit();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("您的计算机没有安装EXCEL!" + "\n" + ex.Message);
                }
      

  7.   

    微软的官方网站有很多精典的例子,
    http://windowsclient.net/
    另外,在
    http://www.codeproject.com
    上也有不少针对具体知识点的例子。