本文介绍了使用COM Interop的c#backgroundworker线程编写多个excel .xlsx文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要问如何从c#backgroundworker线程上的数组列表有问题地创建多个新的Excel电子表格文件

目前,我有一个函数,它通过每个循环和:

xlApp =新的Excel.ApplicationClass();
xlWorkBook = xlApp.Workbooks.Add(misValue);
xlWorkSheet =(Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

然后处理excel对象

通过在backgroundworker线程中执行此操作,将导致各种问题,从空白工作表到多个工作表上的数据拆分.

希望获得有关此操作的任何反馈,基本上想在操作完成时显示选取框进度条,因此如果不使用线程,则需要使用backgroundworker线程,否则进度条将不会移动,导致GUI线程上所有处理的过程

I need to ask how to create multiple new excel spreadsheet files problematically from an arraylist on the c# backgroundworker thread

currently I have a function that goes through a for each loop and :

xlApp = new Excel.ApplicationClass();
xlWorkBook = xlApp.Workbooks.Add(misValue);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

then it disposes of the excel object

by doing this in a backgroundworker thread, it causes all sorts of problems from blank worksheets to data split on multiple worksheets.

Would appreciate any feedback on how to go about this, basically want to show a marquee progressbar when the operation is being done, so I need to use the backgroundworker thread else if I don''t use threading, the progressbar does not move, cause of all processing on the main GUI thread

推荐答案



这篇关于使用COM Interop的c#backgroundworker线程编写多个excel .xlsx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 21:06