Farpoint的簡單用法簡要概述
更新時間:2013年02月15日 10:52:30 作者:
Farpoint操作Excel的功能很強大,這里簡單記錄一下Farpoint的幾個用法(打開Excel模板/保存Excel模板/操作Excel/前臺操作Excel),感興趣的朋友可以了解下
Farpoint操作Excel的功能很強大,這里簡單記錄一下Farpoint的幾個用法.
1.打開Excel模板
this.FpSpread1.OpenExcel(Server.MapPath("../Report/" + strReport)); //打開Excel模板
this.FpSpread1.Sheets[0].AllowPage = false; //是否分頁顯示
this.FpSpread1.Sheets[0].AutoCalculation = true; //是否計算公式
this.FpSpread1.UseClipboard = false; //是否可以使用復制粘貼
this.FpSpread1.Sheets[0].OperationMode = FarPoint.Web.Spread.OperationMode.RowMode; //操作cell的方式(可讀寫)
this.FpSpread1.CommandBar.Visible = false; //是否顯示工具欄
2.保存Excel模板
if (fpSpreadTemplate.SaveExcel(Server.MapPath("../" + strFileName)) == true)
{}
如果保存的時候報錯了.可以考慮給操作Excel的文件夾賦everyone權(quán)限.
如果還是不行可以考慮將你安裝過的farpoint的一個文件夾(fp_client) 配置到你的項目里,然后在webconfig配置節(jié)點
<appSettings>
<add key="fp_client" value="Report/fp_client"/>
</appSettings>
fp_client 文件夾在你安裝的farpoint根目錄內(nèi).
3.操作Excel
//打開模板
fpSpreadTemplate.OpenExcel(Server.MapPath("../Template/" + TEMPLATE));
fpSpreadTemplate.Sheets[0].AllowPage = false;
fpSpreadTemplate.Sheets[0].AutoCalculation = true;
//循環(huán)行和列,遍歷格子
for (int iRow = 0; iRow < fpSpreadTemplate.Sheets[0].RowCount; iRow++)
{
//根據(jù)列遍歷excel
for (int iCol = 0; iCol < fpSpreadTemplate.Sheets[0].ColumnCount; iCol++)
{
//獲取對應格子中的文本值
strCurr = fpSpreadTemplate.Sheets[0].Cells[iRow, iCol].Text;
//為格子內(nèi)容賦值
fpSpreadTemplate.Sheets[0].Cells[iRow, iCol].Text = "ABC";
}
}
4.前臺操作Excel
//使用Farpoint 的FpSpread1_UpdateCommand 事件
protected void FpSpread1_UpdateCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
{
if (fpSpreadTemplate != null)
{
try
{
//這里循環(huán)的某一行的所有列
for (int i = 0; i < e.EditValues.Count; i++)
{
//如果行的第一列是auto說明這個報表需要輸入時間自動賦值的
if (this.FpSpread1.Sheets[0].Cells[Convert.ToInt32(e.CommandArgument), 0].Text.ToString() == "auto")
{
#region
//如果當前沒有編輯過值
if (e.EditValues[i].ToString() != "System.Object")
{
}
#endregion
}
}
}
catch (Exception ex)
{
}
}
}
O(∩_∩)O每天進步一點點O(∩_∩)O 該BLOG供個人記錄學習筆記,如有錯誤歡迎指出!
1.打開Excel模板
復制代碼 代碼如下:
this.FpSpread1.OpenExcel(Server.MapPath("../Report/" + strReport)); //打開Excel模板
this.FpSpread1.Sheets[0].AllowPage = false; //是否分頁顯示
this.FpSpread1.Sheets[0].AutoCalculation = true; //是否計算公式
this.FpSpread1.UseClipboard = false; //是否可以使用復制粘貼
this.FpSpread1.Sheets[0].OperationMode = FarPoint.Web.Spread.OperationMode.RowMode; //操作cell的方式(可讀寫)
this.FpSpread1.CommandBar.Visible = false; //是否顯示工具欄
2.保存Excel模板
復制代碼 代碼如下:
if (fpSpreadTemplate.SaveExcel(Server.MapPath("../" + strFileName)) == true)
{}
如果保存的時候報錯了.可以考慮給操作Excel的文件夾賦everyone權(quán)限.
如果還是不行可以考慮將你安裝過的farpoint的一個文件夾(fp_client) 配置到你的項目里,然后在webconfig配置節(jié)點
復制代碼 代碼如下:
<appSettings>
<add key="fp_client" value="Report/fp_client"/>
</appSettings>
fp_client 文件夾在你安裝的farpoint根目錄內(nèi).
3.操作Excel
復制代碼 代碼如下:
//打開模板
fpSpreadTemplate.OpenExcel(Server.MapPath("../Template/" + TEMPLATE));
fpSpreadTemplate.Sheets[0].AllowPage = false;
fpSpreadTemplate.Sheets[0].AutoCalculation = true;
//循環(huán)行和列,遍歷格子
for (int iRow = 0; iRow < fpSpreadTemplate.Sheets[0].RowCount; iRow++)
{
//根據(jù)列遍歷excel
for (int iCol = 0; iCol < fpSpreadTemplate.Sheets[0].ColumnCount; iCol++)
{
//獲取對應格子中的文本值
strCurr = fpSpreadTemplate.Sheets[0].Cells[iRow, iCol].Text;
//為格子內(nèi)容賦值
fpSpreadTemplate.Sheets[0].Cells[iRow, iCol].Text = "ABC";
}
}
4.前臺操作Excel
復制代碼 代碼如下:
//使用Farpoint 的FpSpread1_UpdateCommand 事件
protected void FpSpread1_UpdateCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
{
if (fpSpreadTemplate != null)
{
try
{
//這里循環(huán)的某一行的所有列
for (int i = 0; i < e.EditValues.Count; i++)
{
//如果行的第一列是auto說明這個報表需要輸入時間自動賦值的
if (this.FpSpread1.Sheets[0].Cells[Convert.ToInt32(e.CommandArgument), 0].Text.ToString() == "auto")
{
#region
//如果當前沒有編輯過值
if (e.EditValues[i].ToString() != "System.Object")
{
}
#endregion
}
}
}
catch (Exception ex)
{
}
}
}
O(∩_∩)O每天進步一點點O(∩_∩)O 該BLOG供個人記錄學習筆記,如有錯誤歡迎指出!
您可能感興趣的文章:
- NPOINT免費虛擬主機管理系統(tǒng)windows2003的安裝方法【圖文】
- asp.net使用npoi讀取excel模板并導出下載詳解
- java使用poi讀取ppt文件和poi讀取excel、word示例
- Java 使用poi把數(shù)據(jù)庫中數(shù)據(jù)導入Excel的解決方法
- java poi讀取excel操作示例(2個代碼)
- jsp連接MySQL操作GIS地圖數(shù)據(jù)實現(xiàn)添加point的功能代碼
- Java中使用Apache POI讀取word文件簡單示例
- Python輸出PowerPoint(ppt)文件中全部文字信息的方法
- java Apache poi 對word doc文件進行讀寫操作
相關(guān)文章
完美解決在ModalPopupExtender中使用CalendarExtender時被層遮擋的問題
ASP.NET AJAX Control Toolkit是一組非常不錯的基于asp.net的ajax控件,它建立在asp.net 3.0的ScriptManager組件之上,提供了很多非常實用的效果和功能。2009-11-11.NET?core項目AsyncLocal在鏈路追蹤中的應用
這篇文章主要為大家介紹了.NET?core項目zhong?AsyncLocal在鏈路追蹤中的應用,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-05-05Asp.net MVC scheduler的實現(xiàn)方法詳解
這篇文章主要介紹了Asp.net MVC scheduler的實現(xiàn)方法詳解的相關(guān)資料,希望通過本文大家能夠?qū)崿F(xiàn)這樣的方法,需要的朋友可以參考下2017-10-10如何利用FluentMigrator實現(xiàn)數(shù)據(jù)庫遷移
這篇文章主要給大家介紹了關(guān)于如何利用FluentMigrator實現(xiàn)數(shù)據(jù)庫遷移的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧2019-04-04.NET Core API之格式化輸出對象OutputFormatter
這篇文章介紹了.NET Core API之格式化輸出對象OutputFormatter,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-04-04利用AJAX與數(shù)據(jù)島實現(xiàn)無刷新綁定
利用AJAX與數(shù)據(jù)島實現(xiàn)無刷新綁定...2007-03-03.net indexOf(String.indexOf 方法)
字符串的IndexOf()方法搜索在該字符串上是否出現(xiàn)了作為參數(shù)傳遞的字符串,如果找到字符串,則返回字符的起始位置 (0表示第一個字符,1表示第二個字符依此類推)如果說沒有找到則返回 -12012-10-10