A brief overview of the simple use of Farpoint

  • 2020-05-24 05:31:35
  • OfStack

The Farpoint operation Excel is very powerful. Here is a simple record of a few USES of Farpoint.
1. Open the Excel template
 
this.FpSpread1.OpenExcel(Server.MapPath("../Report/" + strReport)); // Open the Excel The template  
this.FpSpread1.Sheets[0].AllowPage = false; // Whether to page display  
this.FpSpread1.Sheets[0].AutoCalculation = true; // Whether to calculate the formula  
this.FpSpread1.UseClipboard = false; // Can I use copy and paste  
this.FpSpread1.Sheets[0].OperationMode = FarPoint.Web.Spread.OperationMode.RowMode; // operation cell The way of ( Read/write ) 
this.FpSpread1.CommandBar.Visible = false; // Whether to display the toolbar  

2. Save the Excel template
 
if (fpSpreadTemplate.SaveExcel(Server.MapPath("../" + strFileName)) == true) 
{} 

If an error is reported while saving, consider assigning everyone permissions to the folder where you are operating Excel.
If that doesn't work, consider configuring your farpoint folder (fp_client) to your project, and then configuring the node at webconfig
 
<appSettings> 
<add key="fp_client" value="Report/fp_client"/> 
</appSettings> 

The fp_client folder is in the farpoint root directory you installed.
3. Excel operation
 
// Open the template  
fpSpreadTemplate.OpenExcel(Server.MapPath("../Template/" + TEMPLATE)); 
fpSpreadTemplate.Sheets[0].AllowPage = false; 
fpSpreadTemplate.Sheets[0].AutoCalculation = true; 
// Loop through rows and columns , Traversing lattice  
for (int iRow = 0; iRow < fpSpreadTemplate.Sheets[0].RowCount; iRow++) 
{ 
// Traverse by column excel 
for (int iCol = 0; iCol < fpSpreadTemplate.Sheets[0].ColumnCount; iCol++) 
{ 
// Gets the text value in the corresponding cell  
strCurr = fpSpreadTemplate.Sheets[0].Cells[iRow, iCol].Text; 
// Assign a value to the grid content  
fpSpreadTemplate.Sheets[0].Cells[iRow, iCol].Text = "ABC"; 
} 
} 

4. Front desk operation Excel
 
// use Farpoint  the FpSpread1_UpdateCommand  The event  
protected void FpSpread1_UpdateCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e) 
{ 
if (fpSpreadTemplate != null) 
{ 
try 
{ 
// I'm looping around here 1 All columns of rows  
for (int i = 0; i < e.EditValues.Count; i++) 
{ 
// If the line is 1 The column is auto Note that this report requires automatic time assignment  
if (this.FpSpread1.Sheets[0].Cells[Convert.ToInt32(e.CommandArgument), 0].Text.ToString() == "auto") 
{ 
#region 
// If no value is currently edited  
if (e.EditValues[i].ToString() != "System.Object") 
{ 
} 
#endregion 
} 
} 
} 
catch (Exception ex) 
{ 
} 
} 
} 

O(∩_∩)O daily progress 1 little bit O(∩_∩)O the BLOG is for individuals to take study notes, if there are any errors, please point out!

Related articles: