A brief overview of Farpoint usage

Source: Internet
Author: User

The Farpoint Excel operation function is very powerful. Here we will briefly record several usage of Farpoint.
1. Open an Excel template
Copy codeThe Code is as follows:
This. FpSpread1.OpenExcel (Server. MapPath ("../Report/" + strReport); // open an Excel template
This. FpSpread1.Sheets [0]. AllowPage = false; // whether to display data by PAGE
This. FpSpread1.Sheets [0]. AutoCalculation = true; // whether to calculate the formula
This. FpSpread1.UseClipboard = false; // whether copy and paste can be used
This. FpSpread1.Sheets [0]. OperationMode = FarPoint. Web. Spread. OperationMode. RowMode; // you can read or write a cell)
This. FpSpread1.CommandBar. Visible = false; // whether the toolbar is displayed

2. Save the Excel template
Copy codeThe Code is as follows:
If (fpSpreadTemplate. SaveExcel (Server. MapPath ("../" + strFileName) = true)
{}

If an error is reported during saving, you can assign the everyone permission to the Excel folder.
If the problem persists, you can configure a folder (fp_client) of the farpoint you have installed to your project, and then configure the node in webconfig.
Copy codeThe Code is as follows:
<Deleetask>
<Add key = "fp_client" value = "Report/fp_client"/>
</AppSettings>

The fp_client folder is in the farpoint root directory you have installed.
3. Excel operations
Copy codeThe Code is as follows:
// Open the Template
FpSpreadTemplate. OpenExcel (Server. MapPath ("../Template/" + TEMPLATE ));
FpSpreadTemplate. Sheets [0]. AllowPage = false;
FpSpreadTemplate. Sheets [0]. AutoCalculation = true;
// Loop rows and columns to traverse the grid
For (int iRow = 0; iRow <fpSpreadTemplate. Sheets [0]. RowCount; iRow ++)
{
// Traverse excel by Column
For (int iCol = 0; iCol <fpSpreadTemplate. Sheets [0]. ColumnCount; iCol ++)
{
// Obtain the text value in the corresponding Grid
StrCurr = fpSpreadTemplate. Sheets [0]. Cells [iRow, iCol]. Text;
// Assign values to the grid content
FpSpreadTemplate. Sheets [0]. Cells [iRow, iCol]. Text = "ABC ";
}
}

4. Excel operations on the foreground
Copy codeThe Code is as follows:
// Use the FpSpread1_UpdateCommand event of Farpoint
Protected void FpSpread1_UpdateCommand (object sender, FarPoint. Web. Spread. SpreadCommandEventArgs e)
{
If (fpSpreadTemplate! = Null)
{
Try
{
// All the columns of a Specific Row in this loop
For (int I = 0; I <e. EditValues. Count; I ++)
{
// If the first column of the row is auto, the report must be automatically assigned a value at the specified time.
If (this. FpSpread1.Sheets [0]. Cells [Convert. ToInt32 (e. CommandArgument), 0]. Text. ToString () = "auto ")
{
# Region
// If no value has been edited yet
If (e. EditValues [I]. ToString ()! = "System. Object ")
{
}
# Endregion
}
}
}
Catch (Exception ex)
{
}
}
}

O (TIPS _ Tips) O make a little progress every day O (TIPS _ Tips) O this BLOG is for individuals to record learning notes. If you have any mistakes, please note!

Related Article

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.