Farpoint Operations Excel is very powerful, here a simple record of several farpoint usage.
1. Open Excel template
Copy Code code as follows:
This. Fpspread1.openexcel (Server.MapPath) (". /report/"+ strreport)); Open an Excel template
This. Fpspread1.sheets[0]. Allowpage = false; Whether pagination is displayed
This. Fpspread1.sheets[0]. Autocalculation = true; Whether to calculate formulas
This. Fpspread1.useclipboard = false; Can I use copy and paste
This. Fpspread1.sheets[0]. OperationMode = FarPoint.Web.Spread.OperationMode.RowMode; How the cell is operated (readable and writable)
This.FpSpread1.CommandBar.Visible = false; Whether to show toolbars
2. Save Excel Templates
Copy Code code as follows:
if (Fpspreadtemplate.saveexcel (Server.MapPath) ("..."). /"+ strFileName)" = = True)
{}
If you save the error. You can consider assigning everyone permissions to folders that manipulate Excel.
If it's still not working, you can consider configuring a folder (Fp_client) for your installed farpoint into your project, and then configuring the node in Webconfig
Copy Code code as follows:
<appSettings>
<add key= "fp_client" value= "Report/fp_client"/>
</appSettings>
The Fp_client folder is within the Farpoint root directory you have installed.
3. Operation Excel
Copy Code code as follows:
Open a template
Fpspreadtemplate.openexcel (Server.MapPath) (". /template/"+ Template));
Fpspreadtemplate.sheets[0]. Allowpage = false;
Fpspreadtemplate.sheets[0]. Autocalculation = true;
Looping rows and columns, traversing lattices
for (int irow = 0; IRow < fpspreadtemplate.sheets[0]. ROWCOUNT; irow++)
{
Traverse Excel based on columns
for (int icol = 0; Icol < fpspreadtemplate.sheets[0]. ColumnCount; icol++)
{
Get the text value in the corresponding grid
Strcurr = Fpspreadtemplate.sheets[0]. Cells[irow, Icol]. Text;
Assigning values to grid content
Fpspreadtemplate.sheets[0]. Cells[irow, Icol]. Text = "ABC";
}
}
4. Front desk Operation Excel
Copy Code code as follows:
Fpspread1_updatecommand Events using Farpoint
protected void Fpspread1_updatecommand (object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
{
if (fpspreadtemplate!= null)
{
Try
{
All columns of a row in this loop
for (int i = 0; i < E.editvalues.count; i++)
{
If the first column of the row is auto description This report needs to be automatically assigned in time
if (this. Fpspread1.sheets[0]. Cells[convert.toint32 (E.commandargument), 0]. text.tostring () = = "Auto")
{
#region
If the value is not currently edited
if (e.editvalues[i). ToString ()!= "System.Object")
{
}
#endregion
}
}
}
catch (Exception ex)
{
}
}
}
O (∩_∩) o make a little progress every day O (∩_∩) o this blog for personal record learning notes, if there are errors Welcome to point out!