I have a web app which creates a report on the fly. I would like it to them open and display what I’ve created immediately.
When running on a webserver, I cannot save to C, so what method do I use. Do I NEED to save it first? The following works when I run it locally…
Dim sSQLText As String
sSQLText = "SELECT TheYear ETC"
Using connection As SqlConnection = New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("VisionExtendDevelopmentCS").ConnectionString)
Dim cmd As New SqlCommand()
cmd.Connection = connection
cmd.Connection.Open()
cmd.CommandText = sSQLText
Dim dr As SqlDataReader = cmd.ExecuteReader
Dim license As New Aspose.Words.License
license.SetLicense("Aspose.Total.lic")
Dim doc As Aspose.Words.Document = New Aspose.Words.Document()
Dim builder As New DocumentBuilder(doc)
Dim rowFormat As Tables.RowFormat = builder.RowFormat
Dim font As Aspose.Words.Font = builder.Font
font.Name = "Calibri"
font.Size = "11"
font.Bold = True
builder.StartTable()
builder.InsertCell()
builder.Write("Proposal Results Tracking")
builder.EndRow()
rowFormat.ClearFormatting()
font.Name = "Calibri"
font.Size = "11"
font.Bold = False
builder.InsertCell()
builder.Write("The following data summarizes the " & iSelectedYear & " year to date proposal results:")
builder.EndRow()
While dr.Read
builder.InsertCell()
builder.Write(dr.Item("PropCount") & " Proposals / Qualifications have been initiated")
builder.EndRow()
'ETC
End While
builder.EndTable()
For iSectCount = 0 To doc.Sections.Count - 1
doc.Sections(iSectCount).PageSetup.BottomMargin = "21.6"
doc.Sections(iSectCount).PageSetup.TopMargin = "21.6"
doc.Sections(iSectCount).PageSetup.LeftMargin = "21.6"
doc.Sections(iSectCount).PageSetup.RightMargin = "21.6"
doc.Sections(iSectCount).PageSetup.Orientation = Aspose.Words.Orientation.Landscape
doc.Sections(iSectCount).PageSetup.PaperSize = Aspose.Words.PaperSize.Letter
Next
Dim table As Table = CType(doc.GetChild(NodeType.Table, 0, True), Table)
’ Clear the borders all cells in the table.
table.ClearBorders()
Dim pdfSaveOptions As Aspose.Words.Saving.PdfSaveOptions = New Aspose.Words.Saving.PdfSaveOptions()
Dim sFilename As String
sFilename = "c:\Proposal Results YTD - " & Format(Now, "yyyy-MM-dd-h-mm-ss") & ".pdf"
doc.Save(sFilename, pdfSaveOptions)
System.Diagnostics.Process.Start(sFilename)