Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Workbook wb    = new Workbook();
        Sheet    sheet = wb.OpenSheet("Sheet1");

        // 设置背景
        PageOffice.ExcelWriter.Table backGroundTable = sheet.OpenTable("A1:P200");
        //设置表格边框样式
        backGroundTable.Border.LineColor = Color.White;

        // 设置单元格边框样式
        PageOffice.ExcelWriter.Border C4Border = sheet.OpenTable("C4:C4").Border;
        C4Border.Weight     = PageOffice.ExcelWriter.XlBorderWeight.xlThick;
        C4Border.LineColor  = Color.Yellow;
        C4Border.BorderType = XlBorderType.xlAllEdges;

        // 设置单元格边框样式
        PageOffice.ExcelWriter.Border B6Border = sheet.OpenTable("B6:B6").Border;
        B6Border.Weight     = PageOffice.ExcelWriter.XlBorderWeight.xlHairline;
        B6Border.LineColor  = Color.Purple;
        B6Border.LineStyle  = XlBorderLineStyle.xlSlantDashDot;
        B6Border.BorderType = XlBorderType.xlAllEdges;

        //设置表格边框样式
        PageOffice.ExcelWriter.Table titleTable = sheet.OpenTable("B4:F5");
        titleTable.Border.Weight     = PageOffice.ExcelWriter.XlBorderWeight.xlThick;
        titleTable.Border.LineColor  = Color.FromArgb(0, 128, 128);
        titleTable.Border.BorderType = PageOffice.ExcelWriter.XlBorderType.xlAllEdges;

        //设置表格边框样式
        PageOffice.ExcelWriter.Table bodyTable2 = sheet.OpenTable("B6:F15");
        bodyTable2.Border.Weight     = PageOffice.ExcelWriter.XlBorderWeight.xlThick;
        bodyTable2.Border.LineColor  = Color.FromArgb(0, 128, 128);
        bodyTable2.Border.BorderType = PageOffice.ExcelWriter.XlBorderType.xlAllEdges;

        PageOfficeCtrl1.SetWriter(wb);// 不要忘记此句代码

        PageOfficeCtrl1.AddCustomToolButton("全屏/还原", "IsFullScreen", 4);
        PageOfficeCtrl1.ServerPage = Request.ApplicationPath + "/pageoffice/server.aspx"; //此行必须
        PageOfficeCtrl1.WebOpen("doc/test.xls", PageOffice.OpenModeType.xlsNormalEdit, "张三");
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string userName = Request.Form["userName"];
        //***************************卓正PageOffice组件的使用********************************
        Workbook wb    = new Workbook();
        Sheet    sheet = wb.OpenSheet("Sheet1");

        PageOffice.ExcelWriter.Table tableA = sheet.OpenTable("C4:D6");
        PageOffice.ExcelWriter.Table tableB = sheet.OpenTable("C7:D9");

        tableA.SubmitName = "tableA";
        tableB.SubmitName = "tableB";

        //根据登录用户名设置数据区域可编辑性
        //A部门经理登录后
        if (userName.Equals("zhangsan"))
        {
            Literal1.Text   = "A部门经理,所以只能编辑A部门的产品数据";
            tableA.ReadOnly = false;
            tableB.ReadOnly = true;
        }
        //B部门经理登录后
        else
        {
            Literal1.Text   = "B部门经理,所以只能编辑B部门的产品数据";
            tableA.ReadOnly = true;
            tableB.ReadOnly = false;
        }

        PageOfficeCtrl1.SetWriter(wb);


        PageOfficeCtrl1.AddCustomToolButton("保存", "Save", 1);
        PageOfficeCtrl1.ServerPage = Request.ApplicationPath + "/pageoffice/server.aspx"; //此行必须

        PageOfficeCtrl1.SaveDataPage = "SaveData.aspx";                                   //保存数据
        PageOfficeCtrl1.SaveFilePage = "SaveFile.aspx";                                   //如果需要保存文档,添加此句代码
        PageOfficeCtrl1.WebOpen("doc/test.xls", PageOffice.OpenModeType.xlsSubmitForm, userName);
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        PageOffice.ExcelWriter.Workbook wb = new PageOffice.ExcelWriter.Workbook();
        Sheet sheet = wb.OpenSheet("Sheet1");

        Cell cC3 = sheet.OpenCell("C3");

        //设置单元格背景样式
        cC3.BackColor           = Color.AntiqueWhite;
        cC3.Value               = "一月";
        cC3.ForeColor           = Color.Green;
        cC3.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        Cell cD3 = sheet.OpenCell("D3");

        //设置单元格背景样式
        cD3.BackColor           = Color.AntiqueWhite;
        cD3.Value               = "二月";
        cD3.ForeColor           = Color.Green;
        cD3.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        Cell cE3 = sheet.OpenCell("E3");

        //设置单元格背景样式
        cE3.BackColor           = Color.AntiqueWhite;
        cE3.Value               = "三月";
        cE3.ForeColor           = Color.Green;
        cE3.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        Cell cB4 = sheet.OpenCell("B4");

        //设置单元格背景样式
        cB4.BackColor           = Color.SkyBlue;
        cB4.Value               = "住房";
        cB4.ForeColor           = Color.Wheat;
        cB4.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        Cell cB5 = sheet.OpenCell("B5");

        //设置单元格背景样式
        cB5.BackColor           = Color.Teal;
        cB5.Value               = "三餐";
        cB5.ForeColor           = Color.Wheat;
        cB5.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        Cell cB6 = sheet.OpenCell("B6");

        //设置单元格背景样式
        cB6.BackColor           = Color.MediumPurple;
        cB6.Value               = "车费";
        cB6.ForeColor           = Color.Wheat;
        cB6.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        Cell cB7 = sheet.OpenCell("B7");

        //设置单元格背景样式
        cB7.BackColor           = Color.SteelBlue;
        cB7.Value               = "通讯";
        cB7.ForeColor           = Color.Wheat;
        cB7.HorizontalAlignment = XlHAlign.xlHAlignCenter;

        //绘制表格线
        PageOffice.ExcelWriter.Table titleTable = sheet.OpenTable("B3:E10");
        titleTable.Border.Weight     = PageOffice.ExcelWriter.XlBorderWeight.xlThick;
        titleTable.Border.LineColor  = Color.FromArgb(0, 128, 128);
        titleTable.Border.BorderType = PageOffice.ExcelWriter.XlBorderType.xlAllEdges;

        //合并单元格后赋值
        sheet.OpenTable("B1:E2").Merge();
        sheet.OpenTable("B1:E2").RowHeight = 30;//设置行高
        PageOffice.ExcelWriter.Cell B1 = sheet.OpenCell("B1");
        //设置单元格文本样式
        B1.HorizontalAlignment = PageOffice.ExcelWriter.XlHAlign.xlHAlignCenter;
        B1.VerticalAlignment   = PageOffice.ExcelWriter.XlVAlign.xlVAlignCenter;
        B1.ForeColor           = Color.FromArgb(0, 128, 128);
        B1.Value     = "出差开支预算";
        B1.Font.Bold = true;
        B1.Font.Size = 25;

        PageOfficeCtrl1.SetWriter(wb);                                                    // 不要忘记此句代码

        PageOfficeCtrl1.ServerPage = Request.ApplicationPath + "/pageoffice/server.aspx"; //此行必须
        PageOfficeCtrl1.WebOpen("doc/test.xls", PageOffice.OpenModeType.xlsNormalEdit, "张三");
    }