Excel解析入庫

2021-07-22 14:02:29 字數 3946 閱讀 5983

1.配置資料庫連線字串

1>sqlserver資料庫連線

2>oracle資料庫連線

2.獲取資料庫連線字串(sqlserver)

sql.cs

private static string connstr = configurationmanager.connectionstrings["sql"].connectionstring;

3.解析資料

類:splitcars

城市名測點名

日期so2

no2pm10

co臭氧1小時

臭氧8小時

pm25

aqi首要汙染物

級數級別

汙染程度

超標汙染物

呂梁    

呂梁    

2014-1-1

10445

943.713

3421

5993

一氧化碳2ⅱ

良 excel列的下標從0開始

1>獲取監測站點的名稱

var s = datagridview1[1, i].value.tostring();

2>根據監測站點名稱得到編號

string stationcode = getstationcodeorpoll(datagridview1[1, i].value.tostring());

getstationcodeorpoll()方法

private string getstationcodeorpoll(string code)

return  null;

}3>獲取級別

var level = datagridview1[12, i].value.tostring();

4>首要汙染物

日資料計算:

5.1>co日均值iaqi

short coiaqi = _aqiread.get24hcoiaqi(math.round(decimal.parse(datagridview1[6, i].value.tostring()), 3));

get24hcoiaqi()方法【iiaqiread.cs】

public inte***ce iiaqiread

;private static list> colevels24h = new list>()

;//co24小時平均

public int16 get24hcoiaqi(decimal value)

5.2>no2日均值iaqi

short no2iaqi = _aqiread.get24hno2iaqi(decimal.parse(datagridview1[4, i].value.tostring()));

get24hno2iaqi()方法【iiaqiread.cs】

public inte***ce iiaqiread

;private static list> no2levels24h = new list>()

;//no224小時平均

public int16 get24hno2iaqi(decimal value)

5.3>so2日均值iaqi

short so2iaqi = _aqiread.get24hso2iaqi(decimal.parse(datagridview1[3, i].value.tostring()));

get24hso2iaqi()方法【iiaqiread.cs】

public inte***ce iiaqiread

;private static list> so2levels24h = new list>()

;//so224小時平均

public int16 get24hso2iaqi(decimal value)

5.4>o3日均值iaqi

short o3iaqi = _aqiread.geto3iaqi(decimal.parse(datagridview1[7, i].value.tostring()));

geto3iaqi()方法【iiaqiread.cs】

public inte***ce iiaqiread

;public int16 geto3iaqi(decimal value)

5.5>o38h日均值iaqi

short o38hiaqi = _aqiread.geto38hiaqi(decimal.parse(datagridview1[8, i].value.tostring()));

geto38hiaqi()方法【iiaqiread.cs】

public inte***ce iiaqiread

;public int16 geto38hiaqi(decimal value)

5.6>pm25日均值iaqi

short pm25iaqi = _aqiread.getpm25iaqi(decimal.parse(datagridview1[9, i].value.tostring()));

getpm25iaqi()方法【iiaqiread.cs】

public inte***ce iiaqiread

; public int16 getpm25iaqi(decimal value)

5.7>pm10日均值iaqi

short pm10iaqi = _aqiread.getpm10iaqi(decimal.parse(datagridview1[4, i].value.tostring()));

getpm25iaqi()方法【iiaqiread.cs】

public inte***ce iiaqiread

;public int16 getpm10iaqi(decimal value)

6>sql  insert

if (s != "呂梁")

,,,,,,,,,,,,,,,,,,)",

stationcode, "'" + datagridview1[2, i].value.tostring() + "'",

getvalue(datagridview1[3, i].value.tostring()), so2iaqi, 

getvalue(datagridview1[4, i].value.tostring()), no2iaqi,

math.round(decimal.parse(datagridview1[6, i].value.tostring()), 3), coiaqi,

getvalue(datagridview1[7, i].value.tostring()), o3iaqi,

getvalue(datagridview1[8, i].value.tostring()), o38hiaqi,

getvalue(datagridview1[9, i].value.tostring()), pm25iaqi,

getvalue(datagridview1[5, i].value.tostring()), pm10iaqi,

datagridview1[10, i].value, pollutant, level

);sql.executesql(sql);

}報錯:

解析php入庫和出庫

資料放入資料庫和取出來顯示在頁面需要注意什麼 入庫時 str addslashes str sql in程式設計客棧sert into tab content values str 出庫時 str stripslashes str 顯示時 str htmlspecialchars nl2br str...

shell指令碼nginx日誌解析入庫

bin sh 獲取nigin日誌 log path usr local nginx logs access.log cat log path while read line do 判斷該條資訊是否為我們需要 if line eleid then 替換中 和 的轉譯符 line line echo o...

上傳解析Excel

專案中上傳解析excel的功能,非常普遍,因為方便,接下來就寫乙個工具類對excel進行解析 引入poi 阿帕奇依賴 工具類的書寫public class excelutils else if excel 2007 suffix.equalsignorecase suffixname catch i...