You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.1 KiB
81 lines
2.1 KiB
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
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|