Hello Sir ,Mam
We develope one ERP web application in asp.net with VB.NET backbend SQL server 2008.
We create one export to excel button on project report tab so report(Crystal report) will convert in proper export to excel format.
when we fetch large amount of data by source code it export to excel properly but, When we are expecting same result from publish file
it gets log out (google chrome & Mozila firfox).
we are expecting proper solution for the same so, please guide us.
Thanks & Regards
Suraj

suraj BhoirPosted Jul 9, 2014, 5:41 AM
suraj BhoirPosted Jul 8, 2014, 1:59 AM
divReportContainer.Visible = True
SimplifiEDLVRepot.SeparatePages = True
Dim excel As New Excel.Application
Dim exApp As Object
Dim chartRange As Excel.Range
GC.Collect()
excel = Nothing
exApp = Nothing
excel = New Excel.Application
exApp = New Object()
excel.Workbooks.Add()
excel.SheetsInNewWorkbook = 1
Dim ExcelCount As Int16 = 1
Ds = feed.GetBoardWiseSubmissionReport(Session("project_id"), Session("Franchiseid"))
With excel
.Worksheets(ExcelCount).Select()
.Worksheets(ExcelCount).Shapes.AddPicture(System.Web.HttpContext.Current.Request.MapPath("Excels\logo.jpg"), _
Microsoft.Office.Core.MsoTriState.msoFalse, _
Microsoft.Office.Core.MsoTriState.msoCTrue, 10, 0, 300, 50)
Dim rows As Int16 = 5
Dim cols As Int16 = 1
'report Heading
chartRange = .Worksheets(ExcelCount).Range(.Worksheets(ExcelCount).Cells(rows, 3), .Worksheets(ExcelCount).Cells(rows, 4))
chartRange.Merge()
chartRange.FormulaR1C1 = "Commercial Offer"
chartRange.HorizontalAlignment = HorizontalAlign.Left
chartRange.Font.Size = 16
chartRange.Font.Bold = True
rows += 2
'***************************************
'Display
.Worksheets(ExcelCount).Cells(rows, 1) = "Our Ref. :"
excel.Cells(rows, 1).Font.Bold() = True
excel.Cells(rows, 1).EntireColumn.AutoFit()
.Worksheets(ExcelCount).Cells(rows, 2) = Ds.Tables("BoardSubmission").Rows(0).Item("QtnNo")
excel.Cells(rows, 2).Font.Bold() = True
excel.Cells(rows, 2).EntireColumn.AutoFit()
.Worksheets(ExcelCount).Cells(rows, 8) = "Offer Date :"
excel.Cells(rows, 8).Font.Bold() = True
excel.Cells(rows, 8).EntireColumn.AutoFit()
.Worksheets(ExcelCount).Cells(rows, 9) = Ds.Tables("BoardSubmission").Rows(0).Item("OfferDate")
excel.Cells(rows, 9).Font.Bold() = True
excel.Cells(rows, 9).EntireColumn.AutoFit()
rows += 3
Dim firstpage_header, firstpage_footer As String
' Masterconn.Open() : trans = Masterconn.BeginTransaction
firstpage_header = fillDetails(Session("uid"), 1, Session("qtnno"), Session("projectname"), Session("clientname"), Session("project_id"), trans)
firstpage_footer = fillDetails(Session("uid"), 3, Session("qtnno"), Session("projectname"), Session("clientname"), Session("project_id"), trans)
' trans.Commit() : Masterconn.Close()
If Not Ds.Tables(0) Is Nothing Then
For Each row As DataRow In Ds.Tables(0).Rows
row.Item("address") = firstpage_header
row.Item("contactperson") = firstpage_footer
Next
End If
chartRange = .Worksheets(ExcelCount).Range(.Worksheets(ExcelCount).Cells(rows, 1), .Worksheets(ExcelCount).Cells(rows + 10, 13))
chartRange.Merge()
chartRange.FormulaR1C1 = firstpage_header
chartRange.HorizontalAlignment = HorizontalAlign.Left
chartRange.Font.Bold = True
rows += 11
'Exact records
Dim totalamount As Decimal = 0
Dim cnt As Int16 = 0
Dim a As Int16 = 0
Dim rep_cols As Int16 = 0
sql = "select distinct Boardname from frontview with (nolock) where project_id=" & Session("project_id")
Dim dt_Board As DataTable = Utils.GetDataTable(sql, MicrosoftWebSupport.strConnString)
For Each dr_board As DataRow In dt_Board.Rows
If rep_cols = 0 Then
Ds.Tables("BoardSubmission").DefaultView.RowFilter = "BoardName='" & dr_board(0) & "' "
If Ds.Tables("BoardSubmission").DefaultView.ToTable.Rows.Count > 0 Then
.Worksheets(ExcelCount).Cells(rows, 1) = "No"
excel.Cells(rows, 1).Font.Bold() = True
.Worksheets(ExcelCount).Cells(rows, 1).EntireColumn.AutoFit() : excel.Cells(rows, 1).Borders.LineStyle = LineStyle.SingleLine
.Worksheets(ExcelCount).Cells(rows, 2) = "Switchboard Name"
excel.Cells(rows, 2).Font.Bold() = True
.Worksheets(ExcelCount).Cells(rows, 2).EntireColumn.AutoFit() : excel.Cells(rows, 2).Borders.LineStyle = LineStyle.SingleLine
.Worksheets(ExcelCount).Cells(rows, 3) = "Qty In Nos."
excel.Cells(rows, 3).Font.Bold() = True
.Worksheets(ExcelCount).Cells(rows, 3).EntireColumn.AutoFit() : excel.Cells(rows, 3).Borders.LineStyle = LineStyle.SingleLine
.Worksheets(ExcelCount).Cells(rows, 4) = "Price Per Unit"
excel.Cells(rows, 4).Font.Bold() = True
.Worksheets(ExcelCount).Cells(rows, 4).EntireColumn.AutoFit() : excel.Cells(rows, 4).Borders.LineStyle = LineStyle.SingleLine
.Worksheets(ExcelCount).Cells(rows, 5) = "Amount"
excel.Cells(rows, 5).Font.Bold() = True
.Worksheets(ExcelCount).Cells(rows, 5).EntireColumn.AutoFit() : excel.Cells(rows, 5).Borders.LineStyle = LineStyle.SingleLine
End If
rep_cols = 1
End If
rows += 1
'add description
cnt += 1
.Worksheets(ExcelCount).Cells(rows, 1) = cnt
.Worksheets(ExcelCount).Cells(rows, 1).EntireColumn.AutoFit()
.Worksheets(ExcelCount).Cells(rows, 1).Borders.LineStyle = LineStyle.SingleLine
.Worksheets(ExcelCount).Cells(rows, 2) = Ds.Tables("BoardSubmission").Rows(a).Item("BoardName")
.Worksheets(ExcelCount).Cells(rows, 2).EntireColumn.AutoFit()
.Worksheets(ExcelCount).Cells(rows, 2).Borders.LineStyle = LineStyle.SingleLine
.Worksheets(ExcelCount).Cells(rows, 3) = Ds.Tables("BoardSubmission").Rows(a).Item("BoardQty")
.Worksheets(ExcelCount).Cells(rows, 3).EntireColumn.AutoFit()
.Worksheets(ExcelCount).Cells(rows, 3).Borders.LineStyle = LineStyle.SingleLine
.Worksheets(ExcelCount).Cells(rows, 4) = Format(Math.Round(Val(Ds.Tables("BoardSubmission").Rows(a).Item("OfferCost"))))
.Worksheets(ExcelCount).Cells(rows, 4).NumberFormat = "0.00"
.Worksheets(ExcelCount).Cells(rows, 4).EntireColumn.AutoFit()
.Worksheets(ExcelCount).Cells(rows, 4).Borders.LineStyle = LineStyle.SingleLine
.Worksheets(ExcelCount).Cells(rows, 5) = Val(Ds.Tables("BoardSubmission").Rows(a).Item("BoardQty")) * (Format(Math.Round(Val(Ds.Tables("BoardSubmission").Rows(a).Item("OfferCost")))))
.Worksheets(ExcelCount).Cells(rows, 5).NumberFormat = "0.00"
.Worksheets(ExcelCount).Cells(rows, 5).EntireColumn.AutoFit()
.Worksheets(ExcelCount).Cells(rows, 5).Borders.LineStyle = LineStyle.SingleLine
totalamount = totalamount + Double.Parse(Format(Val(Ds.Tables("BoardSubmission").Rows(a).Item("BoardQty")) * (Format(Math.Round(Val(Ds.Tables("BoardSubmission").Rows(a).Item("OfferCost"))))), "0.00"))
a = a + 1
Next
rows += 1
.Worksheets(ExcelCount).Cells(rows, 4) = "Total Ex-Works Price : "
excel.Cells(rows, 4).Font.Bold() = True
.Worksheets(ExcelCount).Cells(rows, 4).EntireColumn.AutoFit()
excel.Cells(rows, 4).Borders.LineStyle = LineStyle.SingleLine
.Worksheets(ExcelCount).Cells(rows, 5) = totalamount.ToString()
.Worksheets(ExcelCount).Cells(rows, 5).ColumnWidth() = 10
.Worksheets(ExcelCount).Cells(rows, 5).EntireColumn.AutoFit()
excel.Cells(rows, 5).Borders.LineStyle = LineStyle.SingleLine
.Worksheets(ExcelCount).Cells(rows, 5).NumberFormat = "0.00"
rows += 2
chartRange = .Worksheets(ExcelCount).Range(.Worksheets(ExcelCount).Cells(rows, 1), .Worksheets(ExcelCount).Cells(rows, 2))
chartRange.Merge()
chartRange.FormulaR1C1 = "Total Ex-Works Price in Word : "
chartRange.HorizontalAlignment = HorizontalAlign.Left
chartRange.Font.Bold = True
'********************************************************
'Print Address in reports
rows += 8
Dim Address(3) As String
Address = feed.CompanyAddress().Split("|")
chartRange = .Worksheets(ExcelCount).Range(.Worksheets(ExcelCount).Cells(rows, 2), .Worksheets(ExcelCount).Cells(rows, 8))
chartRange.Merge()
chartRange.FormulaR1C1 = Address(0)
chartRange.HorizontalAlignment = HorizontalAlign.Right
chartRange.Font.Bold = True
rows += 1
chartRange = .Worksheets(ExcelCount).Range(.Worksheets(ExcelCount).Cells(rows, 2), .Worksheets(ExcelCount).Cells(rows, 8))
chartRange.Merge()
chartRange.FormulaR1C1 = Address(1)
chartRange.HorizontalAlignment = HorizontalAlign.Right
chartRange.Font.Bold = True
End With
ExcelCount += 1
Dim pathstring As String
pathstring = System.Web.HttpContext.Current.Request.MapPath("Excels\" & filename_report() & "Price Bid.xls")
If File.Exists(pathstring) Then
File.Delete(pathstring)
End If
excel.ActiveWorkbook.SaveAs(pathstring, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal)
excel.ActiveWorkbook.Close()
excel.Quit()
excel = Nothing
Response.ContentType = "application/ms-excel"
Response.AppendHeader("Content-Disposition", "attachment; filename=" & filename_report() & "Price_Bid.xls")
Response.TransmitFile(pathstring)
Response.Flush()
Ravi ShekharPosted Jul 5, 2014, 5:58 AM
Let me know the export code.
Regards,
Ravi