20250112
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using CSVNET;
|
||||
using FastExcel;
|
||||
|
||||
namespace Excel_Test
|
||||
{
|
||||
@@ -19,14 +23,58 @@ namespace Excel_Test
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
//if (openFileDialog1.ShowDialog() == DialogResult.OK)
|
||||
//{
|
||||
// ExcelNet.ExcelReader reader = new ExcelNet.ExcelReader();
|
||||
// var sheets = new List<string>();
|
||||
// sheets = reader.Get_ExcelSheets(openFileDialog1.FileName);
|
||||
// sheets.
|
||||
var settings = new CSVSettings()
|
||||
{
|
||||
FieldDelimiter = ';',
|
||||
TextQualifier = '\'',
|
||||
ForceQualifiers = true
|
||||
};
|
||||
DataTable dt = CSVDataTable.FromFile(@"x:\exceldata.csv",settings);
|
||||
//MessageBox.Show("A");
|
||||
|
||||
//}
|
||||
|
||||
var inputFile = new FileInfo(@"X:\EXCELTESTDATA.xlsx");
|
||||
FastExcel.FastExcel fast = new FastExcel.FastExcel(inputFile, true);
|
||||
Worksheet worksheet0 = fast.Read(1);
|
||||
enuToDatatable(worksheet0);
|
||||
FastExcel.Worksheet ws = new FastExcel.Worksheet();
|
||||
CellRange cs = new CellRange("8", "53",53,8);
|
||||
FastExcel.Cell c;
|
||||
//c= (Cell)Worksheet0.GetCellsInRange(cs);
|
||||
|
||||
|
||||
|
||||
}
|
||||
public static void enuToDatatable(Worksheet worksheet)
|
||||
{
|
||||
IEnumerator enumerator = worksheet.Rows.GetEnumerator();
|
||||
|
||||
int count = 0;
|
||||
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
Row row = (Row)enumerator.Current;
|
||||
|
||||
IEnumerator enumerator1 = row.Cells.GetEnumerator();
|
||||
|
||||
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (enumerator1.MoveNext())
|
||||
{
|
||||
Cell cell = (Cell)enumerator1.Current;
|
||||
dt[i] = int.Parse(cell.Value.ToString());
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user