Example of using owc to develop reports

Source: Internet
Author: User

Developing statistical reports in some management information systems is one of the necessary functions. Many components are used to develop reports. You can use the owc component that comes with Microsoft, which is a Microsoft Office report component and can be seamlessly connected to. net. You can also use open-source. NET components such as zedgraph for development. You can also use the Crystal Report and the report service provided by SQL Server to develop reports. There are many methods, and each has its own strengths. Next, I will introduce an example of the owc development report I used in my previous projects. The Code is as follows. I will not explain it one by one when necessary attention is added to the Code.

Private void drawmonthlyerrortimegraph (datatable dtdata)

{

String strgroup = request. querystring ["group"]. tostring ();

String stryear = request. querystring ["year"]. tostring ();

String strmonth = request. querystring ["month"]. tostring ();

Lbltitle. Text = stryear + "year" + strmonth + "month" + strgroup + "Monthly XXXXX Report ";

// Place user code here to initialize the page

// Create a chartspace object to place charts

Chartspace objcspace = new chartspaceclass ();

// Add a chart to the chartspace object. The add method returns the chart object.

Chchart objchart = objcspace. charts. Add (0 );

// Specify the chart type. The type is from owc. chartcharttypeenum

Objchart. type = chartcharttypeenum. chcharttypelinestackedmarkers;

// Specifies whether a legend is required for a chart.

Objchart. haslegend = true;

// Specify the title

Objchart. hastitle = true;

Objchart. Title. Caption = strgroup + "XXXX Perspective ";

// Graph description of X and Y axes

Objchart. Axes [0]. hastitle = true;

Objchart. Axes [0]. Title. Caption = "X: Date ";

Objchart. Axes [1]. hastitle = true;

Objchart. Axes [1]. Title. Caption = "Y: fault time ";

// Calculate data

/* Categories and values can be represented by a tab-separated string */

String strseriesname_errortime = "fault time ";

Int idays = getmonthdays (stryear, strmonth );

Stringbuilder sbdays = new stringbuilder ();

For (INT I = 1; I <= idays; I ++)

{

Sbdays. append (I. tostring ());

Sbdays. append ('\ t ');

}

String strcategory = sbdays. tostring ();

Stringbuilder strb_errortime = new stringbuilder ();

For (Int J = 1; j <= idays; j ++)

{

If (dtdata. Rows [0] [J. tostring ()]. tostring () = "")

{

Strb_errortimetime.append ("0 ");

}

Else

{

Strb_errortimetime.append (dtdata. Rows [0] [J. tostring ()]. tostring ());

}

Strb_errortime.append ('\ t ');

}

String strvalue_error = strb_errortime.tostring ();

// Add a series

Objchart. seriescollection. Add (0 );

// Specify the name of a series.

Objchart. seriescollection [0]. setdata (chartdimensionsenum. chdimseriesnames,

+ (INT) chartspecialperformancesenum. chdataliteral, strseriesname_stopline );

// Specify a category

Objchart. seriescollection [0]. setdata (chartdimensionsenum. chdimcategories,

+ (INT) chartspecialperformancesenum. chdataliteral, strcategory );

// Specify the value

Objchart. seriescollection [0]. setdata

(Chartdimensionsenum. chdimvalues,

(INT) chartspecialperformancesenum. chdataliteral, strvalue_error );

// Create the relative path of the GIF file.

String filename = "/" + datetime. Now. Hour. tostring () + datetime. Now. Minute. tostring ()

+ Datetime. Now. Second. tostring () + datetime. Now. millisecond. tostring () + ". GIF ";

// Output as a GIF file.

Objcspace. exportpicture (server. mappath ("../tempimage") + filename, "GIF", 650,300 );

// Add the image to placeholder.

String strimagetag = " ";

Placechartstoplinetime. Controls. Add (New literalcontrol (strimagetag ));

}

 

 

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.