G
Guest
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
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