紧急!如何让它跑得更快 [英] URGENT! How to make it to run faster

查看:98
本文介绍了紧急!如何让它跑得更快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一份报告,我必须每月在我的机器上运行它。

我在VB.NET中的代码,我访问AS400到获取数据,anaysie并发送到
预编译的Excel表格。数据包含9000行。


我使用数据表和for循环我在

预先格式化的Excel表格中逐行发送数据。 br />

我的机器是:

P4 3.0GHz超线程

1 GB内存


我还使用最高价值的线程技术来运行报告。

如果我运行报告而不对我的电脑做任何其他事情,那么报告将在b / b
中创建。 4个小时。


上周末我将我的应用程序放到了另一台机器上,我认识到

它的配置比我的PC少。 P4 2.8Ghz + 996MB Ram没有

超线程技术和8小时创建的报告。


我知道我做了很好的编程,但我仍然想知道为什么这样做报告需要很长时间

时间运行。看起来它在1秒内将每行写入excel表。通过

的方式,Excel表格不是以视觉形式打开的,但是我打开它来编写

写。


这是我的代码:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++核心

进口Excel.XlHAlign

进口Excel.XlLineStyle

进口Excel.XlBordersIndex

进口Excel.XlPattern

导入Excel.XlDirection

导入Excel.XlWindowView

导入Excel.XlPageBreak

导入System.IO

Imports System.Globalization

Imports System.Threading


Public Class clsWINEXCEL


''私人

私有UretimDate为字符串

私有行As DataRow

私有tmpTABLE As DataTable

私有myXRow As DataRow

''FRIEND

Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFi leDialog


Public Sub New()

mWriteExcel()

End Sub

#Region" ; WRITE EXCEL w / DIVISION 1000


Private Sub mWriteExcel()


''保存当前的区域设置

Dim thisThread As System.Threading.Thread =

System.Threading.Thread.CurrentThread

Dim originalCulture As System.Globalization.CultureInfo =

thisThread.CurrentUICulture

''创建新的EXCEL流程

Dim oXL As Object = CreateObject(" Excel.Application")''Excel.Application

Dim oWB As Object''Excel.Workbook

Dim oST As Object''Excel.Sheet

Dim oRng As Excel.Range'' Excel.Range


尝试

thisThread.CurrentCulture =新的System.Globalization.CultureInfo(" en-US")

oWB = oXL.Workbooks.Open(FileName:= clsConst.m_ExcelFile,

UpdateLinks:= False,ReadOnly:= False)

Dim oSheet As Excel.Worksheet

使用oWB.ActiveSheet

.Cel ls(3,4).value =" D ?? NEM:" &安培; clsConst.m_DONEM_TARIHI

。细胞(4,4).value =" ?? RETIM:" &安培; UretimDate


oSheet = oWB.ActiveSheet


Dim myRow As Integer = 13

Dim mySIRANO As Integer = 1

Dim mySIRAWORD As String =""


For the row in tmpTABLE.Rows

''ID NO

。细胞(myRow,1).value = row(0)

''RG代码

。细胞(myRow,2).value =排(1)

''RG NAME

。细胞(myRow,3).value = row(2)

''FK NAME

。细胞(myRow,4).value = row(3)

''KSID NO

。细胞(myRow,5)。 value = row(4)

''类型代码

。细胞(myRow,6).value = row(5)

myRow = myRow 1

下一页


在For循环中,每行写1秒钟。


我问我之前的问题似乎没有人可以帮助我。


我也想知道购买带双CPU的新电脑。但是,这台带有

DUAL CPU的新电脑是否能让我的报告更加丰富。


我提前感谢您阅读我的帖子。


Rgds,

Niyazi

Hi

I have a report that I have to run it monthly in my machine.
My code in VB.NET and I access AS400 to get data, anaysie it and send into
pre formated Excel sheet. The data consist of 9000 rows.

I use data table and with for loop I send the data row by row in
pre-formated Excel sheet.

My machine is:
P4 3.0GHz with Hyperthreading
1 GB of memory

I also use thread technology on higest value to run the report.
If I run the report and not doing anything else with my PC the report will
created aproximetly in 4 hours.

Last weekend I put my application to another machine wich I recognize that
it has less configuration then my PC. P4 2.8Ghz + 996MB Ram with no
hyperthreading technology and report created in 8 hours time.

I know I did good programming but I still wonder why this reports takes long
time run. It looks like it writes each row in 1 sec to excel sheet. By the
way Excel sheet is not open as visualy but I opened it programaticaly to
write.

Here is my code:
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++
Imports KR105U
Imports CLS_MAIN
Imports Microsoft.Office.Core
Imports Excel.XlHAlign
Imports Excel.XlLineStyle
Imports Excel.XlBordersIndex
Imports Excel.XlPattern
Imports Excel.XlDirection
Imports Excel.XlWindowView
Imports Excel.XlPageBreak
Imports System.IO
Imports System.Globalization
Imports System.Threading

Public Class clsWINEXCEL

''PRIVATE
Private UretimDate As String
Private row As DataRow
Private tmpTABLE As DataTable
Private myXRow As DataRow
''FRIEND
Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog

Public Sub New()
mWriteExcel()
End Sub
#Region " WRITE EXCEL w/DIVISION 1000 "

Private Sub mWriteExcel()

''Save the current Regional Settings
Dim thisThread As System.Threading.Thread =
System.Threading.Thread.CurrentThread
Dim originalCulture As System.Globalization.CultureInfo =
thisThread.CurrentUICulture

''Create the New EXCEL Process
Dim oXL As Object = CreateObject("Excel.Application") ''Excel.Application
Dim oWB As Object ''Excel.Workbook
Dim oST As Object ''Excel.Sheet
Dim oRng As Excel.Range ''Excel.Range

Try
thisThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
oWB = oXL.Workbooks.Open(FileName:=clsConst.m_ExcelFile,
UpdateLinks:=False, ReadOnly:=False)
Dim oSheet As Excel.Worksheet
With oWB.ActiveSheet
.Cells(3, 4).value = "D??NEM: " & clsConst.m_DONEM_TARIHI
.Cells(4, 4).value = "??RETIM: " & UretimDate

oSheet = oWB.ActiveSheet

Dim myRow As Integer = 13
Dim mySIRANO As Integer = 1
Dim mySIRAWORD As String = ""

For Each row In tmpTABLE.Rows
''ID NO
.Cells(myRow, 1).value = row(0)
''RG CODE
.Cells(myRow, 2).value = row(1)
''RG NAME
.Cells(myRow, 3).value = row(2)
''FK NAME
.Cells(myRow, 4).value = row(3)
''KSID NO
.Cells(myRow, 5).value = row(4)
''TYPE CODE
.Cells(myRow, 6).value = row(5)
myRow = myRow 1
Next

In the For loop it takes 1 second to write each row.

I ask my question before and it seems there is noone to help me.

I am also wondering to buy new PC with dual CPU. But is this new PC with
DUAL CPU make it to run my report much fatser or not.

I thank you in advance for reading my post.

Rgds,
Niyazi

推荐答案

COM interop is昂贵。我会尽量减少COM互操作的次数。


您可以尝试加载数组中的所有值并将此数组影响到

范围。它会在一个互操作调用中复制所有值,而不是每个单元格进行一次互操作...


虽然它似乎不适用在这种情况下,沿着相同的行,在Excel中运行演示文稿宏(可能是使用少量互操作调用从.NET

应用程序创建)的速度更快
而不是每次你使用COM互操作调用从

..NET应用程序运行相同的代码...


作为旁注将消息标记为紧急被视为不良行为

,因为您无法知道其他问题并不像您那样紧急...


-

Patrice


" Niyazi" <镍**** @ discussions.microsoft.com> écritdansle message de news:
8D ********************************** @ microsoft.com < /a> ...
COM interop is costly. I would minimize the number of COM interop calls.

You could try to load all the values in an array and affect this array to a
range. It will copy all the values in a single interop call instead of
making one interop call per cell...

Though it doesn''t seem applicable in this case, along the same lines, it''s
quicker to run a presentation macro in Excel (possibly created from a .NET
application using few interop calls) rather than to run the same code from a
..NET application with a COM interop call each time you hit Excel...

As a side note, marking a message as URGENT is considered as a bad practice
as you have no way to know other problems are not as urgent as yours...

--
Patrice

"Niyazi" <Ni****@discussions.microsoft.com> a écrit dans le message de news:
8D**********************************@microsoft.com...


我有一份报告,我必须每月在我的机器上运行它。
我在VB.NET和我的代码访问AS400以获取数据,并将其发送到预先格式化的Excel表格中。数据包含9000行。

我使用数据表和for循环我在预先格式化的Excel表格中逐行发送数据。

我的机器是:带有超线程的P4 3.0GHz
1 GB的内存

我还使用最高价值的线程技术来运行报告。
如果我运行报告在我的电脑上没有做任何其他事情,报告将在4个小时内完成。

上周末我将我的应用程序放到另一台机器上,我认识到它配置较少那我的电脑。 P4 2.8Ghz + 996MB Ram没有
超线程技术和8小时创建的报告。

我知道我做了很好的编程,但我仍然想知道为什么这个报告需要很长时间<时间运行。看起来它在1秒内将每行写入excel表。通过
方式,Excel表格不是以视觉形式打开的,但是我打开它来编写。

这是我的代码:
+++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +

进口KR105U
进口CLS_MAIN
进口Microsoft.Office.Core
进口Excel.XlHAlign
进口Excel.XlLineStyle
进口Excel。 XlBordersIndex
导入Excel.XlPattern
导入Excel.XlDirection
导入Excel.XlWindowView
导入Excel.XlPageBreak
导入System.IO
导入System.Globalization
Imports System.Threading

Public Class clsWINEXCEL

''PRIVATE
Private UretimDate As String
Private row As DataRow
Private tmpTABLE As DataTable
私有myXRow As DataRow

''FRIEND
Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog

Public Sub New()
mWriteExcel()
结束子

#Region " WRITE EXCEL w / DIVISION 1000

Private Sub mWriteExcel()

''保存当前的区域设置
将thisThread调暗为System.Threading.Thread = < br。> System.Threading.Thread.CurrentThread
Dim originalCulture As System.Globalization.CultureInfo =
thisThread.CurrentUICulture

''创建新的EXCEL流程
昏暗oXL As Object = CreateObject(" Excel.Application")''Excel.Application
Dim oWB As Object''Excel.Workbook
Dim oST As Object''Excel.Sheet
Dim oRng作为Excel.Range''Excel.Range

尝试
thisThread.CurrentCulture = New System.Globalization.CultureInfo(" en-US")
oWB = oXL.Workbooks。打开(FileName:= clsConst.m_ExcelFile,
UpdateLinks:= False,ReadOnly:= False)
Dim oSheet As Excel.Worksheet

with oWB.ActiveSheet
。单元格(3,4).value =" D?NEM: &安培; clsConst.m_DONEM_TARIHI
。细胞(4,4).value ="üRETIM:" &安培; UretimDate

oSheet = oWB.ActiveSheet
将我的整数调整为整数= 13
Dim mySIRANO As Integer = 1
Dim mySIRAWORD As String ="" ;

每行在tmpTABLE.Rows
''ID NO
。细胞(myRow,1).value = row(0)

''RG CODE
。细胞(myRow,2).value = row(1)

''RG NAME
。细胞(myRow,3).value = row( 2)

''FK NAME
。细胞(myRow,4).value = row(3)

''KSID NO
。细胞(myRow,5).value = row(4)

''类型代码
。细胞(myRow,6).value = row(5)

myRow = myRow 1


在For循环中,每行需要1秒钟。

我之前问过我的问题,似乎没有人可以帮帮我。

我也想知道买双CPU的新电脑。但这款带有双CPU的新电脑是否能让我的报告更加丰富。

我提前感谢你阅读我的帖子。

Rgds ,
Niyazi
Hi

I have a report that I have to run it monthly in my machine.
My code in VB.NET and I access AS400 to get data, anaysie it and send into
pre formated Excel sheet. The data consist of 9000 rows.

I use data table and with for loop I send the data row by row in
pre-formated Excel sheet.

My machine is:
P4 3.0GHz with Hyperthreading
1 GB of memory

I also use thread technology on higest value to run the report.
If I run the report and not doing anything else with my PC the report will
created aproximetly in 4 hours.

Last weekend I put my application to another machine wich I recognize that
it has less configuration then my PC. P4 2.8Ghz + 996MB Ram with no
hyperthreading technology and report created in 8 hours time.

I know I did good programming but I still wonder why this reports takes
long
time run. It looks like it writes each row in 1 sec to excel sheet. By the
way Excel sheet is not open as visualy but I opened it programaticaly to
write.

Here is my code:
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++
Imports KR105U
Imports CLS_MAIN
Imports Microsoft.Office.Core
Imports Excel.XlHAlign
Imports Excel.XlLineStyle
Imports Excel.XlBordersIndex
Imports Excel.XlPattern
Imports Excel.XlDirection
Imports Excel.XlWindowView
Imports Excel.XlPageBreak
Imports System.IO
Imports System.Globalization
Imports System.Threading

Public Class clsWINEXCEL

''PRIVATE
Private UretimDate As String
Private row As DataRow
Private tmpTABLE As DataTable
Private myXRow As DataRow
''FRIEND
Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog

Public Sub New()
mWriteExcel()
End Sub
#Region " WRITE EXCEL w/DIVISION 1000 "

Private Sub mWriteExcel()

''Save the current Regional Settings
Dim thisThread As System.Threading.Thread =
System.Threading.Thread.CurrentThread
Dim originalCulture As System.Globalization.CultureInfo =
thisThread.CurrentUICulture

''Create the New EXCEL Process
Dim oXL As Object = CreateObject("Excel.Application") ''Excel.Application
Dim oWB As Object ''Excel.Workbook
Dim oST As Object ''Excel.Sheet
Dim oRng As Excel.Range ''Excel.Range

Try
thisThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
oWB = oXL.Workbooks.Open(FileName:=clsConst.m_ExcelFile,
UpdateLinks:=False, ReadOnly:=False)
Dim oSheet As Excel.Worksheet
With oWB.ActiveSheet
.Cells(3, 4).value = "D?NEM: " & clsConst.m_DONEM_TARIHI
.Cells(4, 4).value = "üRETIM: " & UretimDate

oSheet = oWB.ActiveSheet

Dim myRow As Integer = 13
Dim mySIRANO As Integer = 1
Dim mySIRAWORD As String = ""

For Each row In tmpTABLE.Rows
''ID NO
.Cells(myRow, 1).value = row(0)
''RG CODE
.Cells(myRow, 2).value = row(1)
''RG NAME
.Cells(myRow, 3).value = row(2)
''FK NAME
.Cells(myRow, 4).value = row(3)
''KSID NO
.Cells(myRow, 5).value = row(4)
''TYPE CODE
.Cells(myRow, 6).value = row(5)
myRow = myRow 1
Next

In the For loop it takes 1 second to write each row.

I ask my question before and it seems there is noone to help me.

I am also wondering to buy new PC with dual CPU. But is this new PC with
DUAL CPU make it to run my report much fatser or not.

I thank you in advance for reading my post.

Rgds,
Niyazi



只是一个小想法,您是否考虑过创建一个可以导入的
的CSV文件Excel?


" Patrice" < SC **** @ chez.com>在消息中写道

news:%2 **************** @ TK2MSFTNGP02.phx.gbl ...
Just a small thought, have you considered creating a CSV file that could be
imported into Excel?

"Patrice" <sc****@chez.com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
COM interop很贵。我会尽量减少COM互操作调用的次数。

您可以尝试加载数组中的所有值并将此数组影响到一个范围。它会在一个互操作调用中复制所有值,而不是每个单元格进行一次互操作...

虽然在这种情况下看起来似乎并不适用,但是在同一行中,在Excel中运行演示文稿宏(可能是使用几个互操作调用从.NET
应用程序创建)而不是从.NET应用程序运行相同的代码更快每次你点击Excel时都会有一个COM互操作...

作为旁注,将邮件标记为紧急被认为是一种糟糕的练习,因为你无法知道其他问题并不像你的那样紧急...

-
Patrice

Niyazi <镍**** @ discussions.microsoft.com> écritdansle message de
新闻:
8D ********************************** @ microsoft.com < /a> ...
COM interop is costly. I would minimize the number of COM interop calls.

You could try to load all the values in an array and affect this array to
a range. It will copy all the values in a single interop call instead of
making one interop call per cell...

Though it doesn''t seem applicable in this case, along the same lines, it''s
quicker to run a presentation macro in Excel (possibly created from a .NET
application using few interop calls) rather than to run the same code from
a .NET application with a COM interop call each time you hit Excel...

As a side note, marking a message as URGENT is considered as a bad
practice as you have no way to know other problems are not as urgent as
yours...

--
Patrice

"Niyazi" <Ni****@discussions.microsoft.com> a écrit dans le message de
news: 8D**********************************@microsoft.com...


我有一份报告,我必须每月在我的机器上运行它。
我在VB.NET和我的代码访问AS400以获取数据,并将其发送到
预先格式化的Excel表格中。数据包含9000行。

我使用数据表和for循环我在预先格式化的Excel表格中逐行发送数据。

我的机器是:带有超线程的P4 3.0GHz
1 GB的内存

我还使用最高价值的线程技术来运行报告。
如果我运行报告在我的电脑上没有做任何其他事情,报告将在4个小时内完成。

上周末我将我的应用程序放到另一台机器上,我认识到

它的配置比我的PC少。 P4 2.8Ghz + 996MB Ram没有
超线程技术和8小时创建的报告。

我知道我做了很好的编程,但我仍然想知道为什么这个报告需要很长时间<时间运行。看起来它在1秒内将每行写入excel表。通过
方式,Excel表格不是以视觉方式打开,而是我打开它来编写。

这是我的代码:
+++ ++++++++++++++++++++++++++++++++++++++++++++++++++ +++++

进口KR105U
进口CLS_MAIN
进口Microsoft.Office.Core
进口Excel.XlHAlign
进口Excel.XlLineStyle 导入Excel.XlBordersIndex
导入Excel.XlPattern
导入Excel.XlDirection
导入Excel.XlWindowView
导入Excel.XlPageBreak
导入System.IO
导入System.Globalization
Imports System.Threading

Public Class clsWINEXCEL

''PRIVATE
Private UretimDate As String
Private row As DataRow <私有tmpTABLE作为DataTable
私有myXRow作为DataRow

''FRIEND
Friend WithEvents SaveFileDialog1 As
System.Windows.Forms.SaveFileDialog

Public Sub New()
mWriteExcel()
End Sub

#Region" WRITE EXCEL w / DIVISION 1000

Private Sub mWriteExcel()

''保存当前的区域设置
将thisThread调暗为System.Threading.Thread = < br。> System.Threading.Thread.CurrentThread
Dim originalCulture As System.Globalization.CultureInfo =
thisThread.CurrentUICulture

''创建新的EXCEL流程
昏暗oXL As Object = CreateObject(" Excel.Application")
''Excel.Application
Dim oWB As Object''Excel.Workbook
Dim oST As Object''Excel.Sheet
Dim oRng As Excel.Range''Excel.Range

尝试
thisThread.CurrentCulture = New System.Globalization.CultureInfo(" en-US")
oWB = oXL.Workbooks.Open(FileName:= clsConst.m_ExcelFile,
UpdateLinks:= False,ReadOnly:= False)
Dim oSheet As Excel.Worksheet

with oWB.ActiveSheet
.Cells(3,4).value =" D?NEM:" &安培; clsConst.m_DONEM_TARIHI
。细胞(4,4).value ="üRETIM:" &安培; UretimDate

oSheet = oWB.ActiveSheet
将我的整数调整为整数= 13
Dim mySIRANO As Integer = 1
Dim mySIRAWORD As String ="" ;

每行在tmpTABLE.Rows
''ID NO
。细胞(myRow,1).value = row(0)

''RG CODE
。细胞(myRow,2).value = row(1)

''RG NAME
。细胞(myRow,3).value = row( 2)

''FK NAME
。细胞(myRow,4).value = row(3)

''KSID NO
。细胞(myRow,5).value = row(4)

''类型代码
。细胞(myRow,6).value = row(5)

myRow = myRow 1


在For循环中,每行需要1秒钟。

我之前问过我的问题,似乎没有人可以帮帮我。

我也想知道买双CPU的新电脑。但这款带有双CPU的新电脑能让我的报告更加丰富。

我提前感谢你阅读我的帖子。

Rgds ,
Niyazi
Hi

I have a report that I have to run it monthly in my machine.
My code in VB.NET and I access AS400 to get data, anaysie it and send
into
pre formated Excel sheet. The data consist of 9000 rows.

I use data table and with for loop I send the data row by row in
pre-formated Excel sheet.

My machine is:
P4 3.0GHz with Hyperthreading
1 GB of memory

I also use thread technology on higest value to run the report.
If I run the report and not doing anything else with my PC the report
will
created aproximetly in 4 hours.

Last weekend I put my application to another machine wich I recognize
that
it has less configuration then my PC. P4 2.8Ghz + 996MB Ram with no
hyperthreading technology and report created in 8 hours time.

I know I did good programming but I still wonder why this reports takes
long
time run. It looks like it writes each row in 1 sec to excel sheet. By
the
way Excel sheet is not open as visualy but I opened it programaticaly to
write.

Here is my code:
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++
Imports KR105U
Imports CLS_MAIN
Imports Microsoft.Office.Core
Imports Excel.XlHAlign
Imports Excel.XlLineStyle
Imports Excel.XlBordersIndex
Imports Excel.XlPattern
Imports Excel.XlDirection
Imports Excel.XlWindowView
Imports Excel.XlPageBreak
Imports System.IO
Imports System.Globalization
Imports System.Threading

Public Class clsWINEXCEL

''PRIVATE
Private UretimDate As String
Private row As DataRow
Private tmpTABLE As DataTable
Private myXRow As DataRow
''FRIEND
Friend WithEvents SaveFileDialog1 As
System.Windows.Forms.SaveFileDialog

Public Sub New()
mWriteExcel()
End Sub
#Region " WRITE EXCEL w/DIVISION 1000 "

Private Sub mWriteExcel()

''Save the current Regional Settings
Dim thisThread As System.Threading.Thread =
System.Threading.Thread.CurrentThread
Dim originalCulture As System.Globalization.CultureInfo =
thisThread.CurrentUICulture

''Create the New EXCEL Process
Dim oXL As Object = CreateObject("Excel.Application")
''Excel.Application
Dim oWB As Object ''Excel.Workbook
Dim oST As Object ''Excel.Sheet
Dim oRng As Excel.Range ''Excel.Range

Try
thisThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
oWB = oXL.Workbooks.Open(FileName:=clsConst.m_ExcelFile,
UpdateLinks:=False, ReadOnly:=False)
Dim oSheet As Excel.Worksheet
With oWB.ActiveSheet
.Cells(3, 4).value = "D?NEM: " & clsConst.m_DONEM_TARIHI
.Cells(4, 4).value = "üRETIM: " & UretimDate

oSheet = oWB.ActiveSheet

Dim myRow As Integer = 13
Dim mySIRANO As Integer = 1
Dim mySIRAWORD As String = ""

For Each row In tmpTABLE.Rows
''ID NO
.Cells(myRow, 1).value = row(0)
''RG CODE
.Cells(myRow, 2).value = row(1)
''RG NAME
.Cells(myRow, 3).value = row(2)
''FK NAME
.Cells(myRow, 4).value = row(3)
''KSID NO
.Cells(myRow, 5).value = row(4)
''TYPE CODE
.Cells(myRow, 6).value = row(5)
myRow = myRow 1
Next

In the For loop it takes 1 second to write each row.

I ask my question before and it seems there is noone to help me.

I am also wondering to buy new PC with dual CPU. But is this new PC with
DUAL CPU make it to run my report much fatser or not.

I thank you in advance for reading my post.

Rgds,
Niyazi




我同意Code Rodent,办公室应用程序的定义很慢......我

知道这一点,因为我在2005年编写了一个模板自动化系统

for Word ....


尽量不要直接写入excel,创建一个CSV并通过代码导入它,完成后进入

excel,它会运行得更快!


删除导入excel,当你不需要它们时......


祝你好运


" Niyazi"写道:
I agree with Code Rodent, office applications are by definition slow... I
know this first hand as I have written a template automation system in 2005
for Word....

Try not to write to excel directly, create a CSV and import it by code, into
excel when finished, it will run a lot faster!

Remove the imports for excel, when you don''t need them...

good luck

"Niyazi" wrote:


我有一份报告,我必须每月在我的机器上运行它。
我在VB.NET和我的代码访问AS400以获取数据,并将其发送到预先格式化的Excel表格中。数据包含9000行。

我使用数据表和for循环我在预先格式化的Excel表格中逐行发送数据。

我的机器是:带有超线程的P4 3.0GHz
1 GB的内存

我还使用最高价值的线程技术来运行报告。
如果我运行报告在我的电脑上没有做任何其他事情,报告将在4个小时内完成。

上周末我将我的应用程序放到另一台机器上,我认识到它配置较少那我的电脑。 P4 2.8Ghz + 996MB Ram没有
超线程技术和8小时创建的报告。

我知道我做了很好的编程,但我仍然想知道为什么这个报告需要很长的时间跑。看起来它在1秒内将每行写入excel表。通过
方式,Excel表格不是以视觉形式打开的,但是我打开它来编写。

这是我的代码:
+++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +

进口KR105U
进口CLS_MAIN
进口Microsoft.Office.Core
进口Excel.XlHAlign
进口Excel.XlLineStyle
进口Excel。 XlBordersIndex
导入Excel.XlPattern
导入Excel.XlDirection
导入Excel.XlWindowView
导入Excel.XlPageBreak
导入System.IO
导入System.Globalization
Imports System.Threading

Public Class clsWINEXCEL

''PRIVATE
Private UretimDate As String
Private row As DataRow
Private tmpTABLE As DataTable
私有myXRow As DataRow

''FRIEND
Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog

Public Sub New()
mWriteExcel()
结束子

#Region" WRITE EXCEL w / DIVISION 1000

Private Sub mWriteExcel()

''保存当前的区域设置
将thisThread调暗为System.Threading.Thread = < br。> System.Threading.Thread.CurrentThread
Dim originalCulture As System.Globalization.CultureInfo =
thisThread.CurrentUICulture

''创建新的EXCEL流程
昏暗oXL As Object = CreateObject(" Excel.Application")''Excel.Application
Dim oWB As Object''Excel.Workbook
Dim oST As Object''Excel.Sheet
Dim oRng作为Excel.Range''Excel.Range

尝试
thisThread.CurrentCulture = New System.Globalization.CultureInfo(" en-US")
oWB = oXL.Workbooks。打开(FileName:= clsConst.m_ExcelFile,
UpdateLinks:= False,ReadOnly:= False)
Dim oSheet As Excel.Worksheet

with oWB.ActiveSheet
。单元格(3,4).value =" D ?? NEM: &安培; clsConst.m_DONEM_TARIHI
。细胞(4,4).value =" ?? RETIM:" &安培; UretimDate

oSheet = oWB.ActiveSheet
将我的整数调整为整数= 13
Dim mySIRANO As Integer = 1
Dim mySIRAWORD As String ="" ;

每行在tmpTABLE.Rows
''ID NO
。细胞(myRow,1).value = row(0)

''RG CODE
。细胞(myRow,2).value = row(1)

''RG NAME
。细胞(myRow,3).value = row( 2)

''FK NAME
。细胞(myRow,4).value = row(3)

''KSID NO
。细胞(myRow,5).value = row(4)

''类型代码
。细胞(myRow,6).value = row(5)

myRow = myRow 1


在For循环中,每行需要1秒钟。

我之前问过我的问题,似乎没有人可以帮帮我。

我也想知道买双CPU的新电脑。但这款带有双CPU的新电脑能让我的报告更加丰富。

我提前感谢你阅读我的帖子。

Rgds ,
Niyazi
Hi

I have a report that I have to run it monthly in my machine.
My code in VB.NET and I access AS400 to get data, anaysie it and send into
pre formated Excel sheet. The data consist of 9000 rows.

I use data table and with for loop I send the data row by row in
pre-formated Excel sheet.

My machine is:
P4 3.0GHz with Hyperthreading
1 GB of memory

I also use thread technology on higest value to run the report.
If I run the report and not doing anything else with my PC the report will
created aproximetly in 4 hours.

Last weekend I put my application to another machine wich I recognize that
it has less configuration then my PC. P4 2.8Ghz + 996MB Ram with no
hyperthreading technology and report created in 8 hours time.

I know I did good programming but I still wonder why this reports takes long
time run. It looks like it writes each row in 1 sec to excel sheet. By the
way Excel sheet is not open as visualy but I opened it programaticaly to
write.

Here is my code:
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++
Imports KR105U
Imports CLS_MAIN
Imports Microsoft.Office.Core
Imports Excel.XlHAlign
Imports Excel.XlLineStyle
Imports Excel.XlBordersIndex
Imports Excel.XlPattern
Imports Excel.XlDirection
Imports Excel.XlWindowView
Imports Excel.XlPageBreak
Imports System.IO
Imports System.Globalization
Imports System.Threading

Public Class clsWINEXCEL

''PRIVATE
Private UretimDate As String
Private row As DataRow
Private tmpTABLE As DataTable
Private myXRow As DataRow
''FRIEND
Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog

Public Sub New()
mWriteExcel()
End Sub
#Region " WRITE EXCEL w/DIVISION 1000 "

Private Sub mWriteExcel()

''Save the current Regional Settings
Dim thisThread As System.Threading.Thread =
System.Threading.Thread.CurrentThread
Dim originalCulture As System.Globalization.CultureInfo =
thisThread.CurrentUICulture

''Create the New EXCEL Process
Dim oXL As Object = CreateObject("Excel.Application") ''Excel.Application
Dim oWB As Object ''Excel.Workbook
Dim oST As Object ''Excel.Sheet
Dim oRng As Excel.Range ''Excel.Range

Try
thisThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
oWB = oXL.Workbooks.Open(FileName:=clsConst.m_ExcelFile,
UpdateLinks:=False, ReadOnly:=False)
Dim oSheet As Excel.Worksheet
With oWB.ActiveSheet
.Cells(3, 4).value = "D??NEM: " & clsConst.m_DONEM_TARIHI
.Cells(4, 4).value = "??RETIM: " & UretimDate

oSheet = oWB.ActiveSheet

Dim myRow As Integer = 13
Dim mySIRANO As Integer = 1
Dim mySIRAWORD As String = ""

For Each row In tmpTABLE.Rows
''ID NO
.Cells(myRow, 1).value = row(0)
''RG CODE
.Cells(myRow, 2).value = row(1)
''RG NAME
.Cells(myRow, 3).value = row(2)
''FK NAME
.Cells(myRow, 4).value = row(3)
''KSID NO
.Cells(myRow, 5).value = row(4)
''TYPE CODE
.Cells(myRow, 6).value = row(5)
myRow = myRow 1
Next

In the For loop it takes 1 second to write each row.

I ask my question before and it seems there is noone to help me.

I am also wondering to buy new PC with dual CPU. But is this new PC with
DUAL CPU make it to run my report much fatser or not.

I thank you in advance for reading my post.

Rgds,
Niyazi



这篇关于紧急!如何让它跑得更快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆