Hirdetés
- Gurulunk, WAZE?!
- sh4d0w: Én és a számítógép
- Luck Dragon: Asszociációs játék. :)
- Magga: PLEX: multimédia az egész lakásban
- sziku69: Fűzzük össze a szavakat :)
- D1Rect: Nagy "hülyétkapokazapróktól" topik
- koxx: Amikor a prófécia testet ölt – Finalmouse ULX Prophecy 'Scream' Classic
- Mr Dini: Mindent a StreamSharkról!
- Brogyi: CTEK akkumulátor töltő és másolatai
- sziku69: Szólánc.
Új hozzászólás Aktív témák
-
ubid
senior tag
válasz
sztanozs #3713 üzenetére
nem.
A kód a következő :
BTN eseménye :
private void ImportBtnClick(object sender, RoutedEventArgs e)
{
if (AutomationFactory.IsAvailable)
{
if (InitializeExcel())
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Excel workbook (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm|All files|*.*";
openFileDialog.ShowDialog();
FileInfo fileInfo = openFileDialog.File;
if (fileInfo != null)
{
tbMessages.Text = "The processing may take several minutes. Please wait...\n";
btnImporter.IsEnabled = false;
DoBackGroundWork(fileInfo);
}
}
else
{
MessageBox.Show("Excel is not available.");
}
}
else
{
MessageBox.Show("Automation is not available.");
}
}Ez hívja ugye a DoBackGroundWork -öt :
public FileInfo fileNameProperty { get; set; }
private void DoBackGroundWork(FileInfo f)
{
BackgroundWorker worker = new BackgroundWorker();
fileNameProperty = f;
worker.WorkerReportsProgress = true;
worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
worker.RunWorkerAsync(fileNameProperty);
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
}
void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
btnImporter.IsEnabled = true;
}
void worker_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
int totalSteps = 30;
FileInfo file = e.Argument as FileInfo;
ProcessExcelSheet(file);
for (int i = 1; i <= totalSteps; i++)
{
///.......
}
}
void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
progressBar.Value = e.ProgressPercentage;
}És ugye a ProcessExcelSheet dolgozik sokáig...
Az pedig így néz ki :private void ProcessExcelSheet(FileInfo File)
{
Object missingValue = System.Reflection.Missing.Value;
bool errorHappened = false;
dynamic workbook = excel.Workbooks.Open(File.FullName);
try
{
...............
Új hozzászólás Aktív témák
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!
- Apple Watch
- Parfüm topik
- Ingatlanos topic!
- HiFi műszaki szemmel - sztereó hangrendszerek
- NVIDIA GeForce RTX 5080 / 5090 (GB203 / 202)
- Samsung Galaxy S23 és S23+ - ami belül van, az számít igazán
- Mikrotik routerek
- Gaming notebook topik
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- Eredeti játékok OFF topik
- További aktív témák...
- Iphone 15 Pro Max 512GB Natúr titán
- DELL Latitude 5520 Strapabíró Érintős Laptop 15,6" -65% i7-1185G7 16/512 Iris Xe FHD IPS
- Intel Core i7 10700/RTX3060/16Gb ram/256Gb SSD
- DELL Latitude 5520 Strapabíró Érintős Laptop 15,6" -65% i7-1185G7 16/512 Iris Xe FHD IPS
- DELL Latitude 5520 Strapabíró Érintős Laptop 15,6" -65% i7-1185G7 8/512 Iris Xe FHD IPS
- Honor X8 128GB, Kártyafüggetlen, 1 Év Garanciával
- ÚJ Xiaomi Mi Robot Vacuum Mop Essential robotporszívó feltörlő 2db 1999 Ft
- HIBÁTLAN iPhone 13 mini 128GB Midnight -1 ÉV GARANCIA - Kártyafüggetlen, MS3330
- GYÖNYÖRŰ iPhone 15 Plus 128GB Black -1 ÉV GARANCIA - Kártyafüggetlen, MS3355, 100% Akkumulátor
- HIBÁTLAN iPhone 15 Pro Max 256GB Black Titanium -1 ÉV GARANCIA - Kártyafüggetlen, MS3497
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest