About Aspose's powerful application--execl

Source: Internet
Author: User
Tags field table

protected void Btnconfirg_click (object sender, EventArgs e)        {           genexcel ();        }        //Set the content text color table with a blue text column and a green text column   & nbsp    protected Aspose.Cells.Style Get_content_style (Workbook Workbook, Color clrmy)        {            aspose.cells.style styletitleblue = workbook. Styles[workbook. Styles.add ()];           styletitleblue.horizontalalignment = Textalignmenttype.center;            styletitleblue.font.name = "Arial";           style TitleBlue.Font.Size = 11;           styletitleblue.istextwrapped = true;    &NBSP ;      styletitleblue.font.color = clrmy;           return styletitleblue;& nbsp      }        //General heading styles        protected Aspose.Cells.Style Get_title_style (Workbook Workbook, Color clrmy) & nbsp      {           aspose.cells.style styletitle = workbook. Styles[workbook. Styles.add ()];           styletitle.horizontalalignment = Textalignmenttype.center;  //Title Center alignment            styletitle.verticalalignment = Textalignmenttype.bottom;    //Vertical Bottom alignment                 styletitle.font.name = "Arial";    //font            styletitle.font.size = 11;          //font size            styletitle.istextwrapped = true;    //Wrap             styletitle.font.color = clrmy;      &NBS P    return styletitle;       }      &NBSp;//------------------------------------------------------------------------       //sheet header row, First line style        //------------------------------------------------------------------------       protected Aspose.Cells.Style Set_title_style (Workbook Workbook, Textalignmenttype alicenter)        {           aspose.cells.style style_top = workbook. Styles[workbook. Styles.add ()];           style_top. HorizontalAlignment = Alicenter;                  //title Center align           &NBSP;STYLE_TOP.F Ont. Size = 18;                                //Word Body size            style_top. Font.Color = system.drawing.color.blue;           style_top. Font.isbold = true;    &NBSp      return style_top;       }        protected void Genexcel ()        {           workbook Workbook = new Workbook ();    &N Bsp      worksheet sheet = workbook. worksheets[0];           cells Cells = sheet. cells;            //center alignment style            aspose.cells.style Style_h_c = Workbook. Styles[workbook. Styles.add ()];           style_h_c.horizontalalignment = Textalignmenttype.center;  //Title Center alignment             //---------------------------------------------------- --------------------           //Field table header yellow back front red heading style            //-- ----------------------------------------------------------------------            Aspose.cElls. Style Styletitleyr = workbook. Styles[workbook. Styles.add ()];           styletitleyr.horizontalalignment = Textalignmenttype.center;            styletitleyr.verticalalignment = textalignmenttype.bottom;           styletitleyr.font.name = "Arial";           styletitleyr.font.isbold = True    //Bold            styletitleyr.font.size = 11;          & nbsp;styletitleyr.istextwrapped = true;           styletitleyr.font.color = color.red;        //The word color is red            styletitleyr.foregroundcolor = color.froma#fff F99; ;//color.yellow;           styletitleyr.pattern = backgroundtype.solid;    & nbsp      //------------------------------------------------------------------------           //field content yellow back front red heading style            //---------------------------- --------------------------------------------           aspose.cells.style Styletitleyr _nr = Workbook. Styles[workbook. Styles.add ()];          &NBSP;STYLETITLEYR_NR. HorizontalAlignment = textalignmenttype.center;          &NBSP;STYLETITLEYR_NR. Font.Name = "Arial";          &NBSP;STYLETITLEYR_NR. Font.Size = 11;          &NBSP;STYLETITLEYR_NR. istextwrapped = true;          &NBSP;STYLETITLEYR_NR. Font.Color = color.black;          &NBSP;STYLETITLEYR_NR. Foregroundcolor = color.froma#ffff99;//color.yellow;          &NBSP;STYLETITLEYR_NR. Pattern = backgroundtype.solid;            // Line Gaolekuan settings-------------------------------------    &nbsp      cells. Setrowheight (0, 23.25);           cells. Setrowheight (1,; )          cells. Setcolumnwidth (0, 16.29);           cells. Setcolumnwidth (1, 10.43);           cells. Setcolumnwidth (2, 28.43);           cells. Setcolumnwidth (3, 7);           cells. Setcolumnwidth (4, 9.43);           cells. Setcolumnwidth (5, 17.71);           cells. Setcolumnwidth (6);           cells. Setcolumnwidth (7, 7.86);           cells. Setcolumnwidth (8, 15.43);           cells. Setcolumnwidth (9, 15.43);           cells. Setcolumnwidth (13.43);           cells. Setcolumnwidth (one, 43.71);          cells. Setcolumnwidth (15.29);           cells. Setcolumnwidth (28.86);           cells. Setcolumnwidth (13.57);           cells. Setcolumnwidth (17.43);           cells. Setcolumnwidth (15.14);           cells. Setcolumnwidth (6.57);           cells. Setcolumnwidth (18.14);            // Header style settings-------------------------------------            cells[0, 0]. Putvalue ("Yellow column filled by garment factory");           cells[0, 0]. SetStyle (Set_title_style (Workbook, Textalignmenttype.left));           cells[0, 5]. Putvalue ("Date");           cells[0, 5]. SetStyle (Set_title_style (Workbook, Textalignmenttype.center));  &NBSp        cells[0, 6]. Putvalue ("10/20/2013");           cells[0, 6]. SetStyle (Set_title_style (Workbook, Textalignmenttype.center));           &NBSP;CELLS[1 , 0]. Putvalue ("Garment Style");           cells[1, 0]. SetStyle (Styletitleyr);           cells[1, 12]. SetStyle (Styletitleyr);           cells[1, 12]. Putvalue ("Handover date");           cells[1, 13]. SetStyle (Styletitleyr);           cells[1, 13]. Putvalue ("ship Mode");           cells[1, 14]. SetStyle (Styletitleyr);           cells[1, 14]. Putvalue ("Ship mode CFM by");           cells[1, 15]. SetStyle (Styletitleyr);           cells[1, 15]. Putvalue ("AIR appd by (PRODUCTION TEAM)");    &nbsp     &NBSP;CELLS[1, 1]. Putvalue ("factory#");           cells[1, 2]. Putvalue ("GV PO");           cells[1, 3]. Putvalue ("supplier#");           cells[1, 4]. Putvalue ("Supplier pi#");           cells[1, 5]. Putvalue ("Trims ref#");           cells[1, 6]. Putvalue ("Color-size");           cells[1, 7]. Putvalue ("qty#");           cells[1, 8]. Putvalue ("Read date");           cells[1, 9]. Putvalue ("p/i Confirm Date");           cells[1, 10]. Putvalue ("Remarks");           cells[1, 11]. Putvalue ("Estimate Weight (kgs)");           cells[1, 16]. Putvalue ("Our Ref No.");            cells[1, 17]. Putvalue ("Index");           cells[1, 18]. Putvalue ("Wight");             range title_normal = sheet. Cells.createrange (1, 1, 1, 11);          //General header title            title_normal. SetStyle (Get_title_style (Workbook, Color.Black));            range Title_normal_ End = Sheet. Cells.createrange (1, 16, 1, 3);          //General header title            title_normal_end. SetStyle (Get_title_style (Workbook, Color.Black));            range Title_content_b = Sheet. Cells.createrange (2, 8, 65535, 1);    //Blue content            title_content_b.setstyle (Get_content_style (Workbook, Color.Blue));  //styletitleblue);            range title_contne_g = sheet. Cells.createrange (2, 10, 65535, 1);    //Green content            titLe_contne_g.setstyle (Get_content_style (Workbook, Color.green));  //styletitlegreen);            cells[1, 10]. SetStyle (Get_title_style (Workbook, Color.green));           cells[1, 8]. SetStyle (Get_title_style (Workbook, Color.Blue));            // Column background color settings--------------------------------------           range Range = sheet. Cells.createrange (2, 0, 65535, 1);           range range1 = sheet. Cells.createrange (2, 65535, 4);            range. SetStyle (STYLETITLEYR_NR);           range1. SetStyle (STYLETITLEYR_NR);           //content Settings------------------------------------------             for (int i = 0; i < ten; i++)           &NBSP;{&N Bsp             &NBSP;cells[i + 2, 1]. Putvalue (i.ToString (), true);               cells[i + 2, 2]. Putvalue (i.ToString (), true);               cells[i + 2, 3]. Putvalue (i.ToString (), true);               cells[i + 2, 4]. Putvalue (i.ToString (), true);               cells[i + 2, 5]. Putvalue (i.ToString (), true);               cells[i + 2, 7]. Putvalue (i.ToString (), true);               cells[i + 2, 11]. Putvalue (i.ToString (), true);               cells[i + 2, 16]. Putvalue (i.ToString (), true);               cells[i + 2, 17]. Putvalue ((i + 1). ToString (), true);               cells[i + 2, 18]. Putvalue (i.ToString (), true);           &NBSp    cells[i + 2, 1]. SetStyle (Style_h_c);               cells[i + 2, 2]. SetStyle (Style_h_c);               cells[i + 2, 3]. SetStyle (Style_h_c);               cells[i + 2, 4]. SetStyle (Style_h_c);               cells[i + 2, 5]. SetStyle (Style_h_c);               cells[i + 2, 7]. SetStyle (Style_h_c);               cells[i + 2, 11]. SetStyle (Style_h_c);               cells[i + 2, 16]. SetStyle (Style_h_c);               cells[i + 2, 17]. SetStyle (Style_h_c);               cells[i + 2, 18]. SetStyle (Style_h_c);           }             System.IO.MemoryStream ms = WorkbooK.savetostream ();           byte[] bt = Ms. ToArray ();           workbook. Save (@ "D:\test.xls");       }    

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.