Hirdetés
- Olcsó vs. drága egér: melyiknél érzed meg igazán a különbséget?
- Itt a Microsoft szörnyprocesszora, ami 132 maggal tarolhatja le a felhőt
- Az Inteltől – nem csak az Intelnek
- Alice Recoque-kal mutatná meg Európa hogyan kell szuperszámítógépet építeni
- Pokolian jól elrejtette egyik leghasznosabb hardverét az Intel
Ú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!
- Gamer PC - R7 5800X, RTX 3070 és 16gb RAM + GARANCIA
- Gamer Pc - Ryzen 7 3800X, RTX 3060ti, 16gb RAM
- Acer Nitro 5 Gamer Laptop - 15,6 FHD IPS 144hz/ i7 10750H/ 32GB RAM/ RTX 3050Ti/1,5TB SSD
- Lenovo Thinkpad T14 G3 Golyóálló Üzleti Érintős Laptop 14" -50% i5-1250P 12Mag 16GB/512GB FHD+
- Samsung Odyssey G9 49" Oled 240Hz G-Sync, FreeSync VRR Gamer monitor Eladó
- Apple iPhone 15 128GB, Kártyafüggetlen, 1 Év Garanciával
- HIBÁTLAN iPhone 15 Pro Max 256GB Natural Titanium -1 ÉV GARANCIA -Kártyafüggetlen, 100% Akkumulátor
- Apple iPhone 15 Pro 128GB, Kártyafüggetlen, 1 Év Garanciával
- ÁRGARANCIA! Épített KomPhone Ultra 7 265KF 32/64GB RAM RTX 5070 Ti 16GB GAMER PC termékbeszámítással
- ÁRGARANCIA!Épített KomPhone i5 14600KF 16/32/64GB RAM RTX 5070 12GB GAMER PC termékbeszámítással
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: Laptopműhely Bt.
Város: Budapest


