Creating Reports in ASP.netwith Office Web Components

量化风控核心:信用评分卡模型的设计与迭代全流程 ◦ 动态策略适配:根据评分卡结果动态调整风控流程——高分用户(>750分)秒级放款,中低分用户(600-700分)触发补充资料提交,低分用户(<600分)直接拒绝。◦ 特征有效性监控:每月计算特征IV值,对IV<0.1的低效特征(如“用户星座”)进行淘汰,同时引入新特征(如电商消费数据)。某城商行通过增量学习,评分卡PSI值长期稳定在0.1以下。◦ 数据筛选:整合征信数据(逾期记录、查询次数)、行为数据(消费频次、还款习惯),某银行评分卡纳入150+维度特征,覆盖用户偿债能力、意愿、稳定性等维度; 阅读详情
Inside Microsoft: Reporting Using Pivot Tables 2: Creating Reports in ASP.NET with Office Web Components
Introduction

The previous article of the series introduced PivotTables and showed how the Office Web Components (OWC) PivotTable control can be used in the context of static HTML.

In this article I’ll go on to show you how to use PivotTables in a more dynamic, ASP.NET 1.x-based, environment. I’ll create and explain different types of the PivotTable reports in ASP.NET using C# on server side and JavaScript in the browser. I’ll show the code that creates the PivotTable and binds to the data source on server and client sides and describe how to create the wrapper page for the XML format, if you want to use XML. Finally I’ll touch on security and licensing considerations and explain pros and cons of each solution shown in the article. Advanced topics, like OLAP, are not touched in this article, but I provide the links to read further about these kinds of related topics.

Since Excel uses the PivotTable OWC control when saving sheets with PivotTables, the saved HTML and XML files help to understand the format and usage of XML data files behind the PivotTable control.

System Requirements

The following software components were used when writing and testing the sample code for the article:

* Windows XP + SP1

* Internet Information Service 5.1 or later

* .NET Framework 1.1

* Visual Studio .NET 2003

* MS Excel 2003 and Office Web Components 11 (as part of the MS Office 2003 System)

* Northwind database on a MS SQL Server 2000 (MSDE edition)

* Internet Explorer 6.0 + SP2

Since we demand only the core services of these software components, the concepts reviewed in the article can be applied using other software components too. For example, Windows 2003 can be used instead of XP, or OWC 10.

The minimal configuration required:

* IIS web server running on Windows 2000 or later

* NET Framework 1.x

* Visual Studio .NET 2002 or later

* MS Excel 2000 and Office Web Components 9 (MS Office 2000) or later

* MSDE or SQL Server with the Northwind database installed.

* Internet Explorer 5.0 or later (any browser for server-side solutions, but IE is required for client-side solutions, as it uses an ActiveX control)

Remarks on configuration:

* If you are using IE6 after installing WinXP SP2, the ActiveX control may be blocked. Unblocking can be done by clicking the IE Blocking bar and select Allow blocked content.

* If your database and web browser are on different domains and you would like to access the database directly you should enable Access data sources across domains in the Security Settings in IE.

The Sample Code

The accompanying download contains the following files:

* NWSelect.sql: This is an SQL script to create a new view called SalesData which you will need to install in the Northwind database. Use MS SQL Query Analyzer to run this script. The view contains the sales information that may be important for a business user. You’ll use this view in your PivotTable reports to display information for users throughout the article.

* SalesData.bas: This is a VBA macro to automate the creation of a sample PivotTable in Excel. You can run this code from Excel as it is shown in the Creating PivotTables in Excel section

* NWReport folder: This contains the sample Visual Studio .NET solution. To install the sample, create an IIS virtual directory called NWReport, which points to the folder to which you have installed the solution. Set the value of the dataSource key in the web.config to match to your SQL server name.

Using the PivotTable Component in Visual Studio .NET

The PivotTable component is basically an ActiveX control. Before you use it in Visual Studio .NET as a visual component in your ASP.NET pages, you should add it to the Toolbox as shown in Figure 1.


Figure 1. The PivotTable control in the list of COM Components

The PivotTable components should now appear in the toolbox as shown in Figure 2.


Figure 2. Adding the PivotTable control to the Toolbox

Similarly, if you are intending to use the PivotTable component from your ASP.NET code, you should add a reference to the Microsoft Office Web Components as shown on Figure 3.


Figure 3. Enabling the Office Web Components reference in your project

Additionally you will probably want to include the using OWC11; (or using OWC10;, or using OWC9; if you have Office XP or Office 2000 installed) directive in the header of your code to include the OWC namespace.

Client-Side Usage with a Direct Database Connection

If you place a PivotTable component on your ASP.NET page in design mode you get an empty component in design and runtime mode – these are respectively shown in design.gif and empty.gif.


Figure 4. The PivotTable component without a data connection (design mode)


Figure 5. The PivotTable component without a data connection (runtime)

You’ll want to customize these before use. If you look at the HTML source of the page, you see the PivotTable object with its single XMLData parameter. Notice that this parameter, as its name suggests, really is an XML data parameter.






VALUE=’
10.0.0.5605

msolap.2


’>




Despite the Click here to connect to data caption on the component at design time that you saw earlier in Figure 4, you should connect to data and make other customizations in ASP.NET by right-clicking the component and selecting the Properties menu item. If this does not work for you, try to select the component in the designer and press ALT + ENTER to have the PivotTable Property Pages displayed. Configure the data source to point to the SalesData view of Northwind database in your SQL Server. Notice that once the data connection is configured, new property pages are added to the PivotTable Property Pages dialog box – this is shown in ptprops1.gif and ptprops4.gif.


Figure 6. The PivotTable Property Pages dialog box before the data connection is set

Set the caption of the PivotTable to "Northwind sales report" as shown on ptprops4.gif.


Figure 7. The PivotTable Property Pages dialog box after the data connection is set

After you set the data connection, the design and runtime view of the PivotTable changes: the pivot areas appear and some of the icons on the toolbar are enabled in the runtime view (see Figure 8 and Figure 9), including the Field List button (second from the right on the toolbar), thus enabling your users to drag and drop fields into the areas.


Figure 8. The PivotTable component with a data connection configured (design mode)


Figure 9. The PivotTable component with a data connection configured (runtime mode)

If you look at the HTML source of the page again, you see that the XMLData parameter has grown quite large (in my case it is almost 4000 characters). It now describes all configuration parameters you set on the PivotTable Property Pages dialog box page, including the ConnectionString, so if you use the NWReport1.aspx as it is in the sample code, don’t forget to set this value to reflect your SQL Server name. The following code list shows a manually formatted part of the value in the XMLData parameter.





11.0.0.5531

msolap.2


Provider=SQLOLEDB.1;
Integrated Security=SSPI;
Persist Security Info=True;
Initial Catalog=Northwind;
Data Source=localhost;
Use Procedure for Prepare=1;
Auto Translate=True;
Packet Size=4096;
Workstation ID=machinename;
Use Encryption for Data=False;
Tag with column collation when possible=False



"Northwind"
."dbo"."SalesData"

Northwind sales report




CompanyName
adVarWChar
UniqueName




0
0
0
0
2







Northwind sales report






’>


Although your users at least can start to work with this version, they would be probably prefer to have a PivotTable that is pre-populated with data instead of this empty one. Later in this article I’ll show you how to do this.

Using the XMLData parameter

The previous discussion might have given you the idea that you should simply copy the XMLData parameter from a web-published sheet, so you as the developer don’t need to code the PivotTable fields. Since most developers tend not to be very good at creating Excel PivotTables, those sheets could be provided to them, so the developers just make a live connection to the database. This solution is basically equivalent to a similar solution where one user creates the PivotTable using Excel then publishes it as HTML, and then somebody from the IT publishes it on the corporate intranet.

Since the XMLData parameter may contain the pivot structure and the data in a mixed way, applying this solution means that data is displayed to your users as it was at the time of the publishing Excel pivot as HTML. This issue can be handled manually (users can refresh the pivot by clicking an exclamation icon on the toolbar) or automatically (by calling the the Refresh() method of the PivotTable object from the JavaScript after loading the page).

You’ll see a similar solution where the XMLData parameter is computed server-side on the fly later in the section, Using the XMLData to Create Interactive Solutions.

Scripting the PivotTable Component, Client-Side

In this section you’ll create a solution that is ideal in a typical intranet scenario, when your users can attach to the database directly and you would like to enable them to choose the dimensions of the PivotTable themselves. Implementing this solution you’ll use the PivotTable component with JavaScript. You’ll create a new ASPX page in Visual Studio .NET, put a PivotTable control on it and set its id property to PivotTable in design view. Then you’ll change to HTML view and write some JavaScript code in the window.onload() method.

The Code

The complete code for this is available as the NWReport2.aspx file in the sample code. The web page that results from doing this is shown in Figure 10.


Figure 10. The interactive PivotTable in HTML

The JavaScript code to achieve this is quite long so I’ve presented it in one go below, then I’ll go through the significant lines individually. Note that in the code below, as usual you’ll need to replace the connection string with one that is appropriate to your machine. Note that some long strings have been formatted with extra line breaks for display purposes.





Working through this function, first you must get the reference to the PivotTable object that just created, and its ActiveView property that can be used to manipulate the fields. Also you need to declare a variable for the Constants property that stores some pivot-related constants you’ll use later.

Using these objects you’re now ready to set the data connection and to specify which data fields will be displayed in which area of the PivotTable.


var table = document.all.PivotTable;

var view = table.ActiveView;

var constants = table.Constants;


Next you should set up the connection to SQL Server. In this case you get the data from the SalesData view, alternatively a stored procedure could be executed to return a record set.


table.ConnectionString = "Provider=SQLOLEDB.1;Integrated
Security=SSPI;Initial Catalog=Northwind;Data Source=YourSqlServerName";

table.CommandText = "SELECT * FROM SalesData";


You should add data fields into pivot areas one by one. You can add fields to the pivot areas, for example, the Country field is added to the row area this way:


var country = view.FieldSets("Country");

country.Fields(0).Caption = "Country";

view.RowAxis.InsertFieldSet(country);


The fields of the record set are populated to the FieldSets collection of the view. In this example the OrderDateMonth field is added similarly to the column area.

You can display not only the raw data fields. It is possible to make calculations on the fields, and display the calculated fields. To illustrate how to create calculated fields we create one called Sales, that contains the value of the sales based on the unit price, quantity and discount. You need to create a new FieldSet using the AddFieldSet method to do this.


var sales = view.AddFieldSet("Sales");

var field = sales.AddCalculatedField("Sales", "Sales", "Sales",
"[UnitPrice]*[Quantity]*(1-[Discount])");
sales.Fields(0).Caption = "Sales";


You should specify how data in the data area is aggregated. The aggregation is available for you through using totals. When creating totals you can choose the type of aggregation (for example sum, count, etc.) for the selected field. We create totals using the AddTotal method and add them to the data area. In this example the SumSales total contains the sum of the sales. We set the NumberFormat property to currency.


var totalSales = view.AddTotal("SumSales", field, constants.plFunctionSum);

totalSales.Caption = "Sales";

view.Totals("SumSales").NumberFormat = "$#,##0";

view.DataAxis.InsertTotal(totalSales);


Finally, the code creates a SumQuantity total similarly to show information on the number of products sold.

Visual Customization of the PivotTable

You can set visual effects, like color or font of the different pivot fields and labels. You can set these visual properties on both client and server side. The following code illustrates this by setting some visual properties of the pivot title bar. You can customize pivot areas and other titles similarly.


view.TitleBar.Visible = true;

view.TitleBar.Caption = "Northwind sales report";

view.TitleBar.Font.Underline = constants.owcUnderlineStyleSingle;

view.TitleBar.Font.Bold = true;

view.TitleBar.Font.Name = "Arial";

view.TitleBar.Font.Size = 16;

view.TitleBar.Font.Color = "#006600";

view.TitleBar.BackColor = "#0000AA";


Server Side Usage

Sometimes it is better to build the PivotTable on the server side. This solution is usually preferred if you want to show the PivotTable to your users as a pure HTML table (for example, because they use low-end browsers) or you want to implement some kind of data caching or transformation for your users. This also means that clients don’t need access to the original data source.

General Consideration when Migrating from Client to Server Side

Migrating from client-side JavaScript code to server-side C# code is really straightforward. There are only some basic rules to keep in mind:

* Objects must be declared and created using their types (like PivotTableClass, PivotView, PivotFieldSet, etc.) instead of using the var declaration.

* Constants are defined in enumerations (like PivotTotalFunctionEnum, UnderlineStyleEnum) instead of the Constants property of the PivotTable object.

* Use [] (brackets) instead of (parentheses) when working with arrays.

* The InsertFieldSet() method expects two more parameters, the reference for a PivotFieldSet object before you insert the new field set and a Boolean value indicating if the field set should be removed from any other axis (we will usenull and false for equivalent behavior). These parameters are optional in JavaScript, but required in .NET.

* The InsertTotal() method expects one more parameter, the reference for a PivotTotal object before you insert the new total. (You can use null for equivalent behavior). This parameter is optional in JavaScript, but required in .NET.

Using the XMLData to Create Interactive Solutions

In this section I will show you how to create an interactive PivotTable solution on the server side. It can be used, for example, if the building up of the PivotTable requires server-side decisions (for example, another system determines if a given field should be added to the pivot), or you would like to hide the script that builds the pivot from your users.

The PivotTableClass has an XMLData property that is equivalent to the XMLData parameter you saw previously when I configured the PivotTable from the designer (NWReport1.aspx). If you create and build your PivotTable on the server side, then pass the value of this property to the XMLData parameter of the PivotTable ActiveX object, the PivotTable behaves much the same as when you build it on the client side.

In this case you create a new ASPX page, put a PivotTable control on it, and change the XMLData value in the HTML source like this:


’>


Then you should migrate the client-side JavaScript code to C# as described in the previous section and put this code into the GetXmlData() method of the code-behind file of your page. Finally, you should pass back the value of the XMLData property to the caller.


return(table.XMLData);


Important to note that Visual Studio .NET replaces the value of the XMLData parameter you set above with the default value when you change the designer from HTML view to design view, so if you see an empty PivotTable when viewing this page in your browser, probably that is the reason.

For the sample code, I created the page NWReport3.aspx to demonstrate this technique for you. The output of the page is identical to the output of NWReport2.aspx shown on Figure 10.

Create Static HTML Solutions

If the end-user’s browser does not support ActiveX, or the machine does not have OWC installed or the bandwidth is limited, the PivotTable can be displayed as pure HTML table. Of course this solution has a serious disadvantage: the HTML table is not interactive. In this section I’ll quickly work through this approach.

Using the HTMLData Property

In this example you’ll create the static HTML output from the pivot data instead of interactive reports seen previously. To achieve this result you should create a new ASPX page and drop a PivotTable control on it. Then you can put the code you used in the GetXmlData() method in the previous section in the Page_Load() method, but instead of passing back the XMLData property we write the HTMLData property of the PivotTableClass to the response stream. The HTMLData property contains the HTML formatted PivotTable.


Response.Write(table.HTMLData);


I created NWReport4.aspx to demonstrate this technique for you. The output of the page is shown on Figure 11.


Figure 11. The static PivotTable in HTML

Error handling

Another useful feature of the HTMLData property is that it may contain additional information if some exception is thrown from the component. Typically you’ll see the rather unhelpful System.Runtime.InteropServices.COMException: Unspecified error exception while building your application. Fortunately the message in this exception often contains more details, which you can retrieve using the following try/catch block:


try

{
// PivotTable manipulating code comes here

}

catch(System.Runtime.InteropServices.COMException ex)

{
Response.Clear();
Response.Write(ex.Message + ex.StackTrace);
Response.Write(table.HTMLData);
Response.End();

}


As an example, the result of an incorrectly specified SQL Server name is shown in Figure 12:


Figure 12. Using the HTMLData property to obtain additional information about an error

Using a Wrapper Component as the Data Source

In this section you’ll create a wrapper component on the server side that can be specified as the data source on the client side without having the client directly connect to the data source. This way you can provide the PivotTable functionality for users who have no direct database access either because of lack of user rights on database or because of the network topology (for example, users on the corporate extranet should access the database only from the internal side of the firewall). The wrapper component may come in handy if you would like to create data caching or data manipulating functionality in the middle tier (e.g., the application or the web server).

To achieve this result, you should refer back to the HTML page that was published from the Excel PivotTable in the previous article. Recall a cachedata XML file is also created during the export. This XML file is refreshed each time you save the Excel sheet if you checked the AutoRepublish every time this workbook is saved option when saving the Excel file in HTML format. If you did not, you should save it again to have the refreshed data in the XML. If you check the contents of this file you see that Excel stores the data for the PivotTable in this file in the following structure:




xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"

xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"

xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">


1





…











…


z:row Col1="Vins et alcools Chevalier" Col2="14" Col3="12"/>

…







The schema of the data is defined in the schema element, which contains an attribute element for each column in a row (e.g., a field in the record). The AttributeType element describes the display name and its datatype element the data type for the columns.

The data for the PivotTable is contained within the data element, in which a row element represents a data row. The row element has attributes with names defined in the attribute elements in the schema, these attributes contain the data for a column.

It’s important to note that the PivotTable component is very sensitive to the format of the XML in this file. It means that although the should be equivalent to the format, the PivotTable accepts only the latter format.

In this sample you’ll create a SalesData.aspx page that outputs the data in the XML format I showed above. The file NWReports5.aspx in the sample code demonstrates this technique – it is identical to NWReports2.aspx except that it consumes data from the wrapper page instead of the direct database connection. To achieve this, only the data connection setup part of the JavaScript need be modified. As you can see, in this case you’ll use the Microsoft OLEDB Persistence Provider (mspersist) in the NWReports5.aspx to bind to an XML stream that contains the persisted record set:


table.ConnectionString = "provider=mspersist";

table.CommandText = "salesdata.aspx";


The harder part is the wrapper page (SalesData.aspx). First, you create a GetSalesData() method that queries the database and returns the DataSet to the caller:


public DataSet GetSalesData()

{
{
SqlConnection connection =
new SqlConnection("Integrated Security=SSPI;
Persist Security Info=False;
Initial Catalog=Northwind;
Data Source=" + ConfigurationSettings.AppSettings["dataSource"]);
connection.Open();
SqlCommand getSalesData =
new SqlCommand("SELECT * FROM SalesData", connection);
getSalesData.CommandType = CommandType.Text;
SqlDataAdapter dataAdapter = new SqlDataAdapter(getSalesData);
DataSet salesData = new DataSet();
dataAdapter.Fill(salesData);
connection.Close();
connection.Dispose();
return salesData;
}

}


Next, you should call GetSalesData() from the Page_Load() method of the SalesData.aspx page. Then, after an XSL transformation you write back its content to the Response stream in the required format. The XSL transformation in question transfers the data from the XML format as it was generated from the DataSet into the XML format expected by the PivotTable component – just as you’ve seen in the case of the cachedata XML file. Note that since during the XSL transformation you get data rows in format instead of the format, you’ll need a temporary MemoryStream to read the XML content to a string and replace the wrong format to the right one. Although this isn’t an elegant solution, it must be done to have the PivotTable read the XML.

Notice that calling SalesData.aspx from your browser shows you the transformed XML data, but if you give query string parameters when calling the page (e.g., SalesData.aspx?qqq), the row data XML is passed back. This can help to develop and debug the XSL transformation. The SalesData.xslt used for the transformation is created experimentally, knowing the XML format of the DataSet and the persisted Excel data.


private void Page_Load(object sender, System.EventArgs e)

{
// Get the SalesData and transform it using the XSLT
DataSet salesData = GetSalesData();
XmlDataDocument xmlDataDoc = new XmlDataDocument(salesData);
XslTransform xslTran = new XslTransform();
xslTran.Load(MapPath("SalesData.xslt"));
// Create a memory stream for temporal storage of the result set XML
MemoryStream stream = new MemoryStream();
XmlTextWriter writer =
new XmlTextWriter(stream, System.Text.Encoding.UTF8);
writer.Formatting = Formatting.Indented;
writer.Indentation = 2;
writer.IndentChar = ‘ ‘;
// If the query string is not empty, then we write the data set XML itself
// instead of the transformed XML to the stream
// to help build and debug the XSLT file for transformation
if (Request.QueryString.Count!=0)
{
xmlDataDoc.WriteTo(writer);
}
else
{
xslTran.Transform(xmlDataDoc, null, writer, null);
}
// Flush the writer and reset stream position to the beginning
writer.Flush();
writer.BaseStream.Position = 0;
// Then read to the end of the stream
StreamReader reader = new StreamReader(stream);
string formattedOutput = reader.ReadToEnd();
// Replace row tags to equivalents that are
// acceptable by the PivotTable component
formattedOutput = formattedOutput.Replace(">rn ", "/>");
// Write the result to the Response stream
Response.ContentType = "text/xml";
XmlTextWriter xmlWriter =
new XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8);
xmlWriter.WriteRaw(formattedOutput);
xmlWriter.Close();
Response.End();

}


The output of the NWReport5.aspx is identical to the output of NWReport2.aspx shown earlier in Figure 10.

Choosing your Solution

So far in this article I’ve presented a number of different approaches to providing PivotTables in ASP.NET 1.x pages. In this section I’ll look in a bit more detail at some of the issues surrounding which approach is likely to be best in different situations.

When to Calculate Fields

In the samples in this article you calculated fields from JavaScript and C#. If you prefer, fields can also be calculated in SQL; a simple example is the OrderDateMonth field you calculated from the OrderDate field in the SalesData view:


CHAR(7">RIGHT, os.OrderDate, 102), 5) OrderDateMonth


Alternatively you can calculate fields during the XSL transformation, if you use the wrapper page approach.

The method you choose should depend on whether you want to place the load on SQL Server (this happens if you put field calculations into the SQL stored procedure or database view), or on the web server (as when you use XSLT or server side field computing in C# to calculate fields) or on the client (choose JavaScript to compute fields). Whether you provide the fields you used as the base of the calculation to the PivotTable, or only the calculated fields, will most likely depend primarily on whether the user may need those fields and secondarily on the available bandwidth (although this should not be a problem in the case of an intranet). Remember that recovering the original fields from the PivotTable data is almost always harder than obtaining the PivotTable from those fields, and it may not be possible at all. Think of the aggregation of first name and last name, or using only a part of the information, like in the case of the OrderDateMonth field, where the exact date information is lost during the calculation.

Problems with Interactive OWC

In some cases you may find that the interactive features in OWC are not available for you. In other cases you may get strange warning messages. The reasons for these are given below.

* The full interactive functionality of OWC is only available for the users who have Office installed. Without Office the OWC provides view-only functionality.

* The other thing that may prevent the normal usage of OWC is related to the ActiveX settings in your browser. Since OWC is rendered on the client when you use its interactive mode, the Web browser used to display reports must support ActiveX and ActiveX controls must be enabled. Finally, OWC must be on the client or the client must be able to download OWC.

* Alerts like "This page accesses data on another domain. Do you want to allow this?" are related to the Internet Explorer Security settings and can be handled by assigning the web server to the Trusted Sites zone.

You can find links to more information about these topics in the related links for this article.

Comparing the Solutions

Each sample I provided has advantages and disadvantages. In this section I’ll try to give you an overview of pros and cons to help to choose the method that is the most adequate to your requirements (from the point of network topology, security and performance).

First I should mention that Microsoft recommends using OWC only on the client side with interactive mode. Although using the components on the server side is also possible, try to avoid this setup when scalability of the solution is critical for your business. Further information about this topic can be found in the related links.

The use of the HTMLData to produce static HTML reports is clearly recommended if you don’t want your users to change the content of the report or to get more information by adding other fields to the PivotTable. It’s probably not the best method for advanced users, as it means they can’t change the dimensions of the PivotTable but it may be useful for users unfamiliar with manipulating PivotTables, as it has the simplest user interface (e.g., a simple HTML table). Another advantage is that users do not have access to the data source, since all data access is made by the web server components. You can always use this solution if users do not have an ActiveX capable browser, OWC installed, or a licensed version of Office to support the interactive pivots. Also, this solution will produce the least network traffic as it only transfers the data necessary for displaying the required view in HTML format, and not the whole XML data document. This solution is shown in Figure 13.


Figure 13. Static HTML scenario: Using the HTMLData property

When you have to choose between interactive PivotTables built with JavaScript (Figure 14) or with C# and the XMLData property (Figure 15).


Figure 14. Interactive client-side scenario: JavaScript


Figure 15. Interactive server-side scenario: C#

The decision between the two interactive scenarios should be made in the first instance from considering whether the business logic you use to build the PivotTable is available on the client or whether additional information from the server is required. For example if some other business system or business rules determines whether some field should be added to the PivotTable, that condition is easier to check on the server side. Remember that the method you choose does not affect the fact that the PivotTable from the browser connects using the credentials of the interactive user (although the web server also connects to SQL Server when building the PivotTable on the server side). The C# code is used only to build the XMLData parameter for the PivotTable component, and that parameter tells the browser where to get the data from.

If you would like to hide the PivotTable building logic from your users, you should probably choose the XMLData parameter and thus avoid building the PivotTable on the client side. If your users can’t connect directly from their browser to the database, you should use the XMLData parameter, as in this case the whole XML data document is included in the HTML page, while when using JavaScript, the browser should be able to access the database. Using a wrapper page provides a workaround for this latter limitation.

If you have to create interactive reports but the users don’t have direct access to the database (for security or network reason) or there is no database at all, but you have data available as DataSet from an alternative data source (for example, you read the content of a CSV file into a DataSet), then you have an ideal scenario for using a wrapper page, as in Figure 13. Otherwise, this method is not recommended because of the additional overhead placed on the web server.

Further Work

If you want the the users see to have advanced functionality and the PivotTable to be displayed with corresponding graphs I suggest using another ActiveX object, the Chart component from the OWC suite, in conjunction with the PivotTable. Since most people are visually orientated, displaying graphs and charts for them between the PivotTables would probably assist the effectiveness of their work, as well as their perception of your applications.

Using PivotTable with OLAP systems, like SQL Server 2000 Analysis Services, is an advanced topic, but here – when hierarchical data comes into the scope – is where PivotTables can become exceptionally useful. If you plan to use the PivotTable component (or OWC in general) to build OLAP reporting and business intelligence solutions you can find related articles to help your start in the related links for this article.

Conclusion

In this article I’ve shown you how the PivotTable component of OWC is a powerful tool for data publishing and report generation. You learned how to create both client-side and server-side PivotTables using ASP.NET 1.x. I also demonstrated the use of an XML data wrapper page; this may help to create interactive PivotTables when there is no direct connection between the client and the data source. Finally I presented a short comparison of the different approaches demonstrated in the article, to help you choose the optimal solution for your environment.

Using the techniques demonstrated here you can start to build interactive reports for busines
COSMO-RS理论:流体相热力学预测的核心模型与技术突破 摘要:COSMO-RS模型通过量子化学计算分子表面电荷分布,实现了从微观量子尺度到宏观化工过程的热力学预测。该模型基于介电连续介质理论,将分子表面片段化处理,通过σ-剖面描述电荷分布,并计算片段间的静电失配能和氢键能。其核心算法通过自洽化学势方程求解活度系数,克服了传统模型依赖实验参数的局限。随着技术进步,模型引入了高阶描述符和色散力修正,提升了预测精度。在药物研发、化工分离等领域广泛应用,但仍存在对长程有序结构预测不足等局限性。该模型为复杂体系的热力学性质预测提供了重要理论工具。 阅读详情

相关推荐

别让IO口保护二极管坑了你!实测讲解单片机电流倒灌的三种典型症状与防护

本文深入解析单片机电流倒灌的三大典型症状与防护方案,重点分析STM32等单片机在ADC采样异常、系统假死和通信速率异常中的表现。通过实测数据和电路设计建议,提供从基础二极管隔离到专业隔离器件的分级防护策略,帮助工程师有效预防和解决电流倒灌问题。

weixin_29280219的博客 347

占位

错误一: 清空语句太繁琐? 我想到的除了在模块处写上通用语句调用外,还有一个方法可以很轻松的实现清空。 Dim ctrl As Control For Each ctrl In Me.Controls If TypeOf ctrl Is TextBox Then ctrl.Text = "" End If Next 错误二 结账错误? ...

孙玉玲 281

OpenSpec 从入门到精通:AI 时代的最佳 SDD 范式

同样都是「先写规范再写代码」的开源 SDD 框架,OpenSpec(https://github.com/fission-ai/openspec) 展现出了极高的工程性价比,无论是使用 Claude Code、Cursor 还是 Aider,都可以无缝接入 OpenSpec 的规格管理层。这些问题需要人来做判断,AI 做不了这个主。整个流程跑下来,OpenSpec 产出的效果还是令人满意的,一些前期没有考虑到的细节 AI 都补上了,生成的相关文档也有利于开发人员的知识对齐,可以尝试在团队内部推广。

qq_39093474的博客 932

初探ERP的数据库框架

在ERP的软件中,数据库是它的灵魂。每一个ERP软件都有自己的数据库,而这些数据库中最关键的是数据库框架。那么什么是数据库框架?他的作用是什么?为什么要在安装时搭建数据库框架?本文就来解答这些问题。  在编写ERP,MIS,S/B等数据库的应用程序时,首先要做的一件事就是建立数据库框架,它至少包括:数据库和数据库中的表,当然还有视图、存储过程等,这就是数据库框架(不含具体的数据)。然后是使用vb,...

weixin_30690833的博客 290

[小梅哥FPGA] 如何通过动态重配置实现FPGA时钟的实时频率/相位/占空比调整?

PLL和MMCM是实际存在的硬件电路,用以对输入时钟的负面变化,如抖动、频率变化、相位偏移、占空比失真等进行处理。基于该表,用户在初始化Clk_Wiz后,只需要计算好所需的频率、相位、占空比对应的设置值,使用Xil_Out32函数配置对应寄存器即可。通过上述步骤,在平时的开发调试过程中,亦或是一些对于时钟可能有着实时性要求的设计(如数据采集、图像处理)里,我们便可以在无需重新修改设计的前提下,通过AXI4总线来完成对时钟频率、相位的调控,从而达到缩短设计周期以及让设计适应更多场景的目的。

zgmxs的专栏 2495

【微服务】Spring AI Alibaba Jmus 从部署到项目实战详解

Spring AI Alibaba Jmus 从部署到项目实战详解

congge 4191

用VB进行SQL2000的数据备份和恢复

一、数据备份  备份有两中形式完全备份和差异备份  完全备份:是对数据库进行完整备份,周期比较长,如1周等  差异备份:是对更新备份的数据进行备份,周期比较短,如1小时  命令介绍: Backup Database [数据库名] To Disk=[保存路径和名称] With [其他属性]  代码注释:ServerIP :SQLServer所在机器的 IP       jtsg:SQLServer中

海雅 海的雅致 1238

【OpenClaw企业级智能体实战】第11篇:制造业设备预测性维护实战——OpenClaw+DeepSeek+Prometheus从零搭建(附完整代码)

本文聚焦制造业设备预测性维护的核心痛点,基于OpenClaw v2026.2.1、DeepSeek智能诊断、Prometheus监控等工具,拆解“设备状态监控→智能故障诊断→预测性维护”三大核心场景。从技术原理、算法构建、实操流程到完整代码实现,提供“数据采集→模型训练→智能调度→自动处置”的全链路方案。方案遵循工业安全规范,采用“只读优先、权限最小化”原则,适配中小制造企业落地需求。通过虚拟案例验证,可使设备非计划停机时间下降65%、平均修复时间缩短47%,既适合新手快速入门,也为进阶读者提供架构优化思路

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 606

我的数据访问类

Public Class BqDataClassClass BqDataClass  数据访问类    Dim ldailDataName As String    Dim ldailYN As Boolean = False    Dim ldailConnectionString As String    Dim ldailConn As New Data.OleDb.OleDbConn

cdbqss1的专栏 1060

ZYNQ microblaze boot.bin固化步骤

一,ZYNQ移植软核的原理FPGA规模巨大而且功能复杂,因此设计的每一个部分都从头开始是不切实际的。一种解决的办法是:对于较为通用的部分可以重用现有的功能模块,而把主要的时间和资源用在设计中的那些全新的、独特的部分。这就像是你在开发应用程序的时候就不用直接去写驱动物理硬件的代码,而是直接调用Windows提供的API就行了。

wangjie36的博客 2782

vscode中运行gcc -v命令失败了,提示:gcc不是内部或外部命令...如何解决?

🏆本文收录于 《全栈Bug调优(实战版)》 专栏,该专栏专注于分享我在真实项目开发中遇到的各类疑难Bug及其深层成因,并系统提供高效、可复现的解决思路和实操方案。无论你是刚入行的新手开发者,还是拥有多年项目经验的资深工程师,本专栏都将为你提供一条系统化、高质量的问题排查与优化路径,助力你加速成长,攻克技术壁垒,迈向技术价值最大化与职业发展的更高峰🚀!

**My Coding Family** 976

数据库连接的位置

我是每个页面都新建一个连接,然后打开,关闭。 配置都存放在每个页面。虽然没有改动过,可是如果将来要改的话就麻烦了。 在网上查阅了一下,发现可以在web.config里面写入连接字符串,然后在每个页面里面引用。是这样引用的: 在web.config里面加入: <appSettings> <add key="SQLConnectionStr...

395

Python 3.13.7 (64-bit)安装弹窗提示:Setup failed:0x80070643 - 安装时发生严重错误...如何解决?

🏆本文收录于 《全栈Bug调优(实战版)》 专栏,该专栏专注于分享我在真实项目开发中遇到的各类疑难Bug及其深层成因,并系统提供高效、可复现的解决思路和实操方案。无论你是刚入行的新手开发者,还是拥有多年项目经验的资深工程师,本专栏都将为你提供一条系统化、高质量的问题排查与优化路径,助力你加速成长,攻克技术壁垒,迈向技术价值最大化与职业发展的更高峰🚀!

**My Coding Family** 2118

SQL SERVER 2000连接字符串

SQL SERVER 2000连接字符串

zhangxiaonanwin的专栏 5806

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

delphi开发日志——注入“思想”,让程序操纵数据

程序虽然已经具有启动画面,然后登录进入主窗体,可是没有任何灵魂,不能与数据库进行交互,这次我们来让程序来操纵数据。 接着前面,先创建一个DataModule1容器,用于存放数据组件,并命名为:frmDM,单元名为untDM.pas。 在frmDM窗口放入数据库连接组件,用于连接数据库,ADOConnection1,并命名为:conDB,然后设置它的属性:ConnectionString为Pro...

weixin_34245169的博客 166

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

QLIKVIEW如何写增量加载脚本

Qlikview增量加载数据库里的数据到QVD文件。 MainTab: LET LastReload=reloadtime(); LET Curr=now(); TRACE >>>>; SET ThousandSep=','; SET DecimalSep='.'; SET MoneyThousandSep=','; SET MoneyDecimalSep='.'; SET Mo

Watson的专栏 4770

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

找不到存储过程 ‘Password‘。

declare @dbpwd as nvarchar(50) declare @dbcatalog as nvarchar(50) declare @dbserver as nvarchar(50) declare @accid as nvarchar(50) declare @dbpwdgo as nvarchar(50) set @dbpwd = '12345679a' set @dbcatalog = 'UFDATA_999_2014' set @dbserver = 'U8V13...

ruixun8的博客 929

增量加载

Qlikview增量加载数据库里的数据到QVD文件。 MainTab:LET LastReload=reloadtime();LET Curr=now();TRACE <<<<< Current Time is $(Curr), Last Reload Time is $(LastReload)>>>>>;SET ThousandSep...

weixin_30632899的博客 177

Web 版翻译者资料库

本项目是桌面版《翻译者资料库》的 Web 移植版,基于 Spring Boot 3.3、Thymeleaf、Bootstrap 5.3 与 MySQL 8.0 构建。它面向翻译写作提供资料、词汇、句库、文本工具、对照制作、查找、备份恢复及旧库迁移等功能,完整继承桌面版核心业务规则,支持一键启动与离线访问。

howard2005的专栏 147

V8 机制、手写核心函数与 TypeScript 类型体操

或固定初始化(如数组先定长、对象先给全字段)保持类型与形状稳定;这些都比"换框架"更基础。只能处理纯数据(丢函数、Date、RegExp、循环引用报错)。生产级深拷贝要处理:原始值短路、循环引用、V8(Chrome / Node 的 JS 引擎)不是"解释一行跑一行"那么简单,它用。图:V8 执行流程——解释执行 + 热点优化,优化失败会 Deopt 回退。JS 内存自动管理,但"自动"不等于"不会漏"。是"固定间隔最多执行一次"。手写 Promise 是"懂异步"的试金石。是"停下后才执行最后一次",

qq_38468358的博客 350

副队长BootStrap5探究(2)--按钮与按钮组

本文系统讲解Bootstrap 5按钮组件的使用与底层原理。通过CDN引入框架,掌握btn基础类及primary、success等主题色应用,学习轮廓按钮(btn-outline-*)、尺寸控制(btn-lg/sm)、块级布局(d-block)和禁用状态(disabled)等实用功能。结合源码解析,深入理解其基于CSS的圆角、过渡动画、伪类交互实现机制,实现“快速上手+原理掌握”的双重目标,助力前端技能进阶。

编程副队长 670

DSH (DeepSeek Harness) Windows 升级安装指南20261107

注意:如果在普通窗口执行 nvm 提示找不到命令,或执行 nvm use 提示 Access is denied,请务必关闭当前窗口,重新打开一个管理员CMD 执行上述完整路径命令。找到 .credentials.yaml,将其重命名为 .credentials.yaml.bak(备份并使其失效)。Node.js Storage Location:可改到非系统盘(如 D:\dev\nvm,避免路径含空格或中文)。打开文件资源管理器,进入 C:\Users<你的用户名>.dsh\。

fengye207161的博客 213

SpringBoot「衣依」服装销售平台:144个Java文件180个接口,从挑衣服到收货评价整条链路都在

# SpringBoot「衣依」服装销售平台:144个Java文件180个接口,从挑衣服到收货评价整条链路都在 > 这是一套基于 Spring Boot 的服装销售平台源码,配套 `db.sql` 建表脚本,业务覆盖商品展示、购物车、订单流转、收货地址、订单评价、商品评论、在线客服、轮播图和资讯。形态是**前后台双端**:前台是顾客逛的商城,后台是管理员管的控制台。本文带你看清里面有什么、怎么跑

面朝大海 226

微信小程序-wxs

在微信开发者工具中右键创建.wxs后缀的文件。每个.wxs文件也是一个独立模块,同样使用导出内容。示例(文件return d;FOO: foo,bar: bar(外联定义参考官方文档)

dreams_dream的博客 350
上一篇: CSA in Clustered Enviroment
下一篇: 透视表组件编程模型
mindva
博客等级 码龄19年 2粉丝 61原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值