Comments (3)
Original comment by jetcat
on 12 Feb 2009 at 3:31
- Changed state: Accepted
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
from excellibrary.
Original comment by jetcat
on 12 Feb 2009 at 3:32
from excellibrary.
Workbook book = Workbook.Load(filename);
Worksheet sheet = book.Worksheets[0];
if (sheet.Cells.Rows.Count > 0)
{
DataTable tab = new DataTable();
Row HeadRow = sheet.Cells.GetRow(0);
DataColumn dc;
//把第一行当成列标题 the First Row is ColumName
for (int a = 0; a < HeadRow.LastColIndex; a++)
{
dc = new DataColumn(HeadRow.GetCell(a).StringValue);
tab.Columns.Add(dc);
}
for (int rowIndex = sheet.Cells.FirstRowIndex + 1; rowIndex <= sheet.Cells.LastRowIndex; rowIndex++)
{
DataRow dr = tab.NewRow();
Row row = sheet.Cells.GetRow(rowIndex);
for (int colIndex = row.FirstColIndex; colIndex <= row.LastColIndex; colIndex++)
{
//Can not use row.GetCell(colIndex).Format.FormatType
if (HeadRow.GetCell(colIndex).StringValue.IndexOf("日期") >= 0)
{
Double df = double.Parse(row.GetCell(colIndex).StringValue);
DateTime dt= DateTime.FromOADate(df);
dr[colIndex] = dt.ToString("yyyy-MM-dd HH:mm:ss");
}
else { dr[colIndex] = row.GetCell(colIndex).StringValue; }
}
tab.Rows.Add(dr);
}
book = null;
sheet = null;
dgv.DataSource = tab;
Original comment by [email protected]
on 15 Nov 2013 at 8:43
from excellibrary.
Related Issues (20)
- how to insert hyperlink to excel sheet from application
- Generating excel files does not work on windows 8.1 excel 2013
- Signed Assembly
- Unable to read XLS file (file is corrupted) HOT 1
- File with less than 100 rows causes corruption
- Column size set
- I am unable to open the .xls files which I have created earlier. HOT 1
- Code to close the file?
- Load() give's me the error, Buffer cannot be null. I can't open excel files.
- me123
- put string to cell keyword not working
- WrapText issue
- Can't Read From Client Machine To Server Code
- How to set right align in excel cell
- aa
- aaa
- sss
- 222
- xlsx format
- Issue while opening excel file "Security Alert - Office File Validation"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from excellibrary.