using System;
using System.Collections. Generic ;
using System.Data;
using System.Data.OleDb;
using System.IO;
using System.Linq;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
* This source code was highlighted with Source Code Highlighter .
using System;
using System.Collections. Generic ;
using System.Data;
using System.Data.OleDb;
using System.IO;
using System.Linq;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
* This source code was highlighted with Source Code Highlighter .
using System;
using System.Collections. Generic ;
using System.Data;
using System.Data.OleDb;
using System.IO;
using System.Linq;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
* This source code was highlighted with Source Code Highlighter .
public delegate void MessageHave( string message);
public delegate void _DataLoaded( List < string > data);
public delegate void _NewProcent( int col);
public static _DataLoaded DataLoaded;
public static _NewProcent NewProcent;
public static MessageHave MessageHave_Event;
public static void ReadData( object data)
{
// " "-" "
var keyValuePair = (KeyValuePair< string , string >)data;
using ( var cnn = new OleDbConnection( @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
keyValuePair.Key + @";Extended Properties=" "Excel 12.0;HDR=No;IMEX=1" "" )
)
{
int calc = 1000;
MessageHave_Event( " " );
cnn.Open();
try
{
var cmd = new OleDbCommand( String .Format( "select * from [{0}]" , keyValuePair.Value), cnn);
using (OleDbDataReader dr = cmd.ExecuteReader())
{
var lines = new List < string >();
int id = 0;
if (dr != null )
while (dr.Read())
{
string text = "" ;
for ( int i = 0; i < dr.FieldCount; ++i)
{
if (dr[i] != null )
text += dr[i] + "^" ; //
else
text += "^" ;
}
lines.Add(text);
id++;
if (id == calc)
{
NewProcent(id);
calc += 1000;
}
}
DataLoaded(lines);
}
cnn.Close();
}
catch (Exception ex)
{
MessageHave_Event( "Exception: " + ex.Message);
cnn.Close();
}
}
}
* This source code was highlighted with Source Code Highlighter .
public delegate void MessageHave( string message);
public delegate void _DataLoaded( List < string > data);
public delegate void _NewProcent( int col);
public static _DataLoaded DataLoaded;
public static _NewProcent NewProcent;
public static MessageHave MessageHave_Event;
public static void ReadData( object data)
{
// " "-" "
var keyValuePair = (KeyValuePair< string , string >)data;
using ( var cnn = new OleDbConnection( @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
keyValuePair.Key + @";Extended Properties=" "Excel 12.0;HDR=No;IMEX=1" "" )
)
{
int calc = 1000;
MessageHave_Event( " " );
cnn.Open();
try
{
var cmd = new OleDbCommand( String .Format( "select * from [{0}]" , keyValuePair.Value), cnn);
using (OleDbDataReader dr = cmd.ExecuteReader())
{
var lines = new List < string >();
int id = 0;
if (dr != null )
while (dr.Read())
{
string text = "" ;
for ( int i = 0; i < dr.FieldCount; ++i)
{
if (dr[i] != null )
text += dr[i] + "^" ; //
else
text += "^" ;
}
lines.Add(text);
id++;
if (id == calc)
{
NewProcent(id);
calc += 1000;
}
}
DataLoaded(lines);
}
cnn.Close();
}
catch (Exception ex)
{
MessageHave_Event( "Exception: " + ex.Message);
cnn.Close();
}
}
}
* This source code was highlighted with Source Code Highlighter .
public delegate void MessageHave( string message);
public delegate void _DataLoaded( List < string > data);
public delegate void _NewProcent( int col);
public static _DataLoaded DataLoaded;
public static _NewProcent NewProcent;
public static MessageHave MessageHave_Event;
public static void ReadData( object data)
{
// " "-" "
var keyValuePair = (KeyValuePair< string , string >)data;
using ( var cnn = new OleDbConnection( @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
keyValuePair.Key + @";Extended Properties=" "Excel 12.0;HDR=No;IMEX=1" "" )
)
{
int calc = 1000;
MessageHave_Event( " " );
cnn.Open();
try
{
var cmd = new OleDbCommand( String .Format( "select * from [{0}]" , keyValuePair.Value), cnn);
using (OleDbDataReader dr = cmd.ExecuteReader())
{
var lines = new List < string >();
int id = 0;
if (dr != null )
while (dr.Read())
{
string text = "" ;
for ( int i = 0; i < dr.FieldCount; ++i)
{
if (dr[i] != null )
text += dr[i] + "^" ; //
else
text += "^" ;
}
lines.Add(text);
id++;
if (id == calc)
{
NewProcent(id);
calc += 1000;
}
}
DataLoaded(lines);
}
cnn.Close();
}
catch (Exception ex)
{
MessageHave_Event( "Exception: " + ex.Message);
cnn.Close();
}
}
}
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/139706/