輸出FeatureClass中的屬性表

2021-09-20 10:07:49 字數 2267 閱讀 7360

/// /// 輸出要素類的屬性表

///

///

///

public static void createexcelfile(ifeatureclass pfeatureclass, string filepath)

else

// 建立行

npoi.ss.usermodel.isheet sheet = workbook.createsheet("屬性表");

sheet.defaultcolumnwidth = 150 * 256;

npoi.ss.usermodel.irow row = sheet.createrow(0);

row.heightinpoints = 40;

icellstyle headercellstyle = workbook.createcellstyle();

headercellstyle.fillforegroundcolor = npoi.hssf.util.hssfcolor.lime.index;

headercellstyle.fillpattern = fillpattern.solidforeground;

headercellstyle.borderbottom = npoi.ss.usermodel.borderstyle.thin;

headercellstyle.bordertop = npoi.ss.usermodel.borderstyle.thin;

headercellstyle.borderleft = npoi.ss.usermodel.borderstyle.thin;

headercellstyle.borderright = npoi.ss.usermodel.borderstyle.thin;

ifont headerfont = workbook.createfont();

headerfont.boldweight = (short)fontboldweight.bold;

headerfont.fontheightinpoints = 14;

headercellstyle.setfont(headerfont);

headercellstyle.verticalalignment = verticalalignment.center;//垂直居中 方法1

headercellstyle.alignment = npoi.ss.usermodel.horizontalalignment.centerselection;//設定居中 方法2

npoi.ss.usermodel.icell cell = null;

// 寫入列名

int columncount = pdatatable.columns.count;

for (int i = 0; i < columncount; i++)

icellstyle rowcellstyle = workbook.createcellstyle();

rowcellstyle.borderleft = npoi.ss.usermodel.borderstyle.thin;

rowcellstyle.borderright = npoi.ss.usermodel.borderstyle.thin;

rowcellstyle.bordertop = npoi.ss.usermodel.borderstyle.thin;

rowcellstyle.borderbottom = npoi.ss.usermodel.borderstyle.thin;

rowcellstyle.verticalalignment = verticalalignment.center;//垂直居中 方法1

rowcellstyle.alignment = npoi.ss.usermodel.horizontalalignment.centerselection;//設定居中 方法2

// 寫入列值

int rowcount = pdatatable.rows.count;

for (int i = 0; i < rowcount; i++)

}// 寫入檔案

system.io.filestream filestream = new system.io.filestream(filepath, system.io.filemode.create);

workbook.write(filestream);

workbook.close();

filestream.close();

}

engine 刪除FeatureClass 方法

一 幾種刪除方法 1.查詢結果中刪除 private void delete1 ifeatureclass pfeatureclass iqueryfilter pqueryfilter new queryfilterclass pqueryfilter.whereclause objectid d...

判斷Featureclass的型別

乙個featureclass可以是shapefile feature class personal geodatabase feature class file geodatabase feature class等多種選擇。判斷其型別可從以下介面中獲得。1.featurelayer的話,可以直接從i...

獲取和更新FeatureClass的Extent

在featureclass中編輯,刪除,或新增要素後,可用如下的 手動更新一下其extent ifeatureclassmanage pfeatureclass updateextent 獲取圖層extent的方法為 igeodataset pfeatureclass extent 或根據圖層中的所...