asp.net動態獲取Excel表名的代碼
複製代碼 代碼如下:
public string GetExcelFirstTableName(string excelFileName)
{
string tableName = null;
if (ts(excelFileName))
{
using (OleDbConnection conn = new OleDbConnection("Provider=." +
"OLEDB.4.0;Extended Properties="Excel 8.0";Data Source=" + excelFileName))
{
();
DataTable dt = leDbSchemaTable(es, null);
for (int i = 0; i < t; i++)
{
tableName += [i][2]ring()();
view sourceprint?1 }
}
}
return tableName;
}
讀取excel動態獲取表名
複製代碼 代碼如下:
string a=ring();
string excelFilePath=a;
ication myExcel=new icationClass( ) ;
object oMissing = e ;
(excelFilePath,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing) ;
book myBook = books[1] ;
sheet mySheet = (sheet)sheets[1] ;
e();
string Name=;
Table dt=new Table("mytable");
("F1", ype("ng"));
("F2", ype("ng"));
("F3", ype("ng"));
("F4", ype("ng"));
("F5", ype("ng"));
DataSet myDs = new DataSet();
(dt);
DataRow myRow;
r();
for( int i = 2 ; i <= 4 ; i ++ ) //第一行爲標題,不讀取
{
myRow = es["mytable"]ow();
for( int j = 1 ; j <= 5 ; j ++ )
{
e r=(e)s[i,j];
string strValue=ring();
string aa=strValue;
string columnname="F"+ring();
myRow[columnname]=strValue;
}
es["mytable"](myRow);
// }
();
Source=es["mytable"]ultView;
Bind();
相關文章
-
The Sprint in College Entrance Exam英語作文
The period of high school stage is the preparation for college, all the students work hard in the purpose of the better future. In this stage, they hold the same target, fighting for the College Entra -
託福英語寫作範文:Examinations exert a pernicious influence on educat
We might marvel at the progress made in every field of study, but the methods of testing a person’s knowledge and ability remain as primitive as ever they were. It really is extraordinary that after -
英語優秀作文:M Unfrgettable Experiences
I thin evee have unfrgettable experiences . I a glad t share experiences nw . The are all unique , but the are nt alwas the st iprtant things . Fr exaple , I reeber ne da I a in the indergaten . On th -
Asp.Net數據輸出到EXCEL表格中的教程
一、定義文檔類型、字符編碼r();er= true;set="utf-8";//下面這行很重要, attachment 參數表示作爲附件下載,您可以改成 online在線打開//filename= 指定輸出文件的名稱,注意其擴展名和指定文件類型相符,可以爲: ndHeade -
人教PEP版國小五年級英語下冊Unit3Myschoolcalender.ALet’stalk
本部分學習的核心句型是:Whenistheparty?It’sinApril.教材通過Mike和張鵬對校歷上四、五月要舉行的活動的討論場景,介紹了孩子們在春天將有很多趣味性活動的情景,即四月的運動會個萬聖節聚會、五月的春遊,讓學生感知上述 -
雅思口語範文:My Experience as an English Learner
I began leaing English in the middle school. Soon I became very interested in it. English exams were very easy to me and I always got the highest marks in my class. Then I succeeded in the College Ent -
英語作文:An unforgettable experience
One moing before class, when I was running into the classroom, I knocked over the ink bottle on the teacher's desk, and the red ink spilt on the desk. I was sure I would be scolded by the teacher. Just -
高中優秀英語作文An Unforgettable Experience
高中優秀英語作文An Unforgettable ExperienceThis summer holiday, I went to Dalian with my family. We got there by air. Dalian is a very beautiful and mode city. On the bus, we could see all kinds o -
Unforgettable experience 難忘的一件事作文
Unforgettable experience 難忘的一件事It was a sunny day today,when i got up in the moing,i decided to see my i took the bus got there at noon,they were happy to see me,and i was very happy,too.In the -
英語閱讀:TheTwelveDancingPrincesses
There was a king who had twelve beautiful daughters. They slept in twelve beds all in one room and when they went to bed, the doors were shut and locked up. However, every moing their shoes were found