真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Asp.Net怎么用OWC操作Excel-創(chuàng)新互聯(lián)

小編給大家分享一下Asp.Net怎么用OWC操作Excel,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

新都ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!

代碼如下:


    string connstr = System.Configuration.ConfigurationManager.ConnectionStrings["DqpiHrConnectionString"].ToString();
        SqlConnection conn = new SqlConnection(connstr);
        SqlDataAdapter sda = new SqlDataAdapter(sql1.Text, conn);
        DataSet ds = new DataSet();
        conn.Open();
        sda.Fill(ds);
        conn.Close();
        OWC10.SpreadsheetClass xlsheet;
        xlsheet= new OWC10.SpreadsheetClass();
        DataRow dr;
        int i = 0;
        for(int ii=0;ii        {
            dr = ds.Tables[0].Rows[ii];
            //合并單元格
            xlsheet.get_Range(xlsheet.Cells[i+1, 1], xlsheet.Cells[i+1, 8]).set_MergeCells(true);
            xlsheet.get_Range(xlsheet.Cells[i + 5, 1], xlsheet.Cells[i + 5, 3]).set_MergeCells(true);
            xlsheet.get_Range(xlsheet.Cells[i + 5, 4], xlsheet.Cells[i + 5, 6]).set_MergeCells(true);
            xlsheet.get_Range(xlsheet.Cells[i + 5, 7], xlsheet.Cells[i + 5, 8]).set_MergeCells(true);
            xlsheet.ActiveSheet.Cells[i + 1, 1] = dr["姓名"].ToString() + "自然情況";
            //字體加粗
            xlsheet.get_Range(xlsheet.Cells[i + 1, 1], xlsheet.Cells[i + 1, 14]).Font.set_Bold(true);
            //單元格文本水平居中對齊
            xlsheet.get_Range(xlsheet.Cells[i + 1, 1], xlsheet.Cells[i + 1, 14]).set_HorizontalAlignment(OWC10.XlHAlign.xlHAlignCenter);
            //設(shè)置字體大小
            xlsheet.get_Range(xlsheet.Cells[i + 1, 1], xlsheet.Cells[i + 1, 14]).Font.set_Size(14);
            //設(shè)置列寬
            xlsheet.get_Range(xlsheet.Cells[i + 1, 8], xlsheet.Cells[i + 1, 8]).set_ColumnWidth(20);
            //畫邊框線
            xlsheet.get_Range(xlsheet.Cells[i + 1, 1], xlsheet.Cells[i+5, 8]).Borders.set_LineStyle(OWC10.XlLineStyle.xlContinuous);
            //寫入數(shù)據(jù)  (這里由DS生成)
            xlsheet.ActiveSheet.Cells[i + 2, 1] = "姓名";
            xlsheet.ActiveSheet.Cells[i + 2, 2] = dr["姓名"].ToString();
            xlsheet.ActiveSheet.Cells[i + 2, 3] = "曾用名";
            xlsheet.ActiveSheet.Cells[i + 2, 4] = dr["曾用名"].ToString();
            xlsheet.ActiveSheet.Cells[i + 2, 5] = "出生年月";
            xlsheet.ActiveSheet.Cells[i + 2, 6] = DateTime.Parse(dr["出生年月"].ToString()).Year.ToString() + "-" + DateTime.Parse(dr["出生年月"].ToString()).Month.ToString();
            xlsheet.ActiveSheet.Cells[i + 2, 7] = " 參加工作時間";
            xlsheet.ActiveSheet.Cells[i + 2, 8] = DateTime.Parse(dr["參加工作時間"].ToString()).Year.ToString() + "-" + DateTime.Parse(dr["參加工作時間"].ToString()).Month.ToString();
            xlsheet.ActiveSheet.Cells[i + 3, 1] = "性別";
            xlsheet.ActiveSheet.Cells[i + 3, 2] = dr["性別"].ToString();
            xlsheet.ActiveSheet.Cells[i + 3, 3] = "民族";
            xlsheet.ActiveSheet.Cells[i + 3, 4] = dr["民族"].ToString();
            xlsheet.ActiveSheet.Cells[i + 3, 5] = "政治面貌";
            xlsheet.ActiveSheet.Cells[i + 3, 6] = dr["政治面貌"].ToString();
            xlsheet.ActiveSheet.Cells[i + 3, 7] = "職稱";
            xlsheet.ActiveSheet.Cells[i + 3, 8] = dr["職稱"].ToString();
            xlsheet.ActiveSheet.Cells[i + 4, 1] = "學(xué)歷";
            xlsheet.ActiveSheet.Cells[i + 4, 2] = dr["學(xué)歷"].ToString();
            xlsheet.ActiveSheet.Cells[i + 4, 3] = "學(xué)位";
            xlsheet.ActiveSheet.Cells[i + 4, 4] = dr["學(xué)位"].ToString();
            xlsheet.ActiveSheet.Cells[i + 4, 5] = "職務(wù)";
            xlsheet.ActiveSheet.Cells[i + 4, 6] = dr["職務(wù)"].ToString();
            xlsheet.ActiveSheet.Cells[i + 4, 7] = "檔案號碼";
            //Excel不支持0開頭輸入,加上姓氏首字母正好是編號全稱
            xlsheet.ActiveSheet.Cells[i + 4, 8] = dr["姓氏首字母"].ToString() + dr["檔案號碼"].ToString();
            xlsheet.ActiveSheet.Cells[i + 5, 1] = "現(xiàn)從事專業(yè):" + dr["現(xiàn)從事專業(yè)"].ToString();
            xlsheet.ActiveSheet.Cells[i + 5, 4] = "工作單位:" + dr["工作單位"].ToString();
            xlsheet.ActiveSheet.Cells[i + 5, 7] = "身份證:" + dr["身份證號"].ToString();
            i += 6;
        }
        try
        {
            string D = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() +
            DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString()+
            DateTime.Now.Millisecond.ToString();
            xlsheet.Export(Server.MapPath("./")+"\\"+D+".xls", OWC10.SheetExportActionEnum.ssExportActionNone, OWC10.SheetExportFormat.ssExportXMLSpreadsheet);
            Response.Write("");
        }
        catch
        {
        }
    }


以上是“Asp.Net怎么用OWC操作Excel”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!


名稱欄目:Asp.Net怎么用OWC操作Excel-創(chuàng)新互聯(lián)
轉(zhuǎn)載來源:http://weahome.cn/article/dopdss.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部