Monday, September 12, 2011

Copy File Forever

Hey Yo, Darth, My DUDE,

How's it hangin there Darth, buddy?   Cooleo!  You da MAN!

Just a quick note this morning since I've been pretty much ignoring all the other shit that your buggy software has been doing lately.  But this one I figure is worth your attention.   Minor thing, but ... anyway, here you go.

This dialog box has been copying my file to the backup USB Flash drive... it's been saying 5 Minutes for about 20 minutes so far.   Dude, you're killing me here.   Can you stop with the fucking "Estimated Time" already?  It's fucking bullshit.   You used to do the right thing, which was show how much of the file was actually transfered and how much is left remaining as the scroll bar.  That was fine.   So it jumped a bit while processing delayed momentarily.  Big fucking deal.   But instead some genius over there (was it you?) decided it would be much crueler and more unusual to have the progress bar just wave back and forth providing zero useful information except for "I'm working on it, maybe".   That kinda sucks, Darth.  Please fix it.   Put back the old way, and it'll all work out fine.  Thanks.

Friday, July 8, 2011

Excel Streaming Code

Here is my Level 5 Code on Excel Streaming.   As you can see it works to send a string to excel through the browser.   The user is then prompted to open or save the file.   You can use HTML to create excel output with formatting such as column colors, and fonts.   Try it out and let me know if it works for you.   It might do the trick to help you if you're interested in how to do this sort of thing.

------------------------------------------------------------------------------------------------------------------

Dim strPrintOut As String = BuildOutputString(StoredProcedureName, aryParameters())
                   
Call PrintToExcel(strPrintOut, "MyFirstExcelStreamingDoc", Me.Page)


        Public Sub PrintToExcel(ByVal strPrintOut As String, ByVal FileName As String, ByVal pg As Page)
            Try

                Dim worksheetTitle = ""
                Dim strHeader As String = ""

                worksheetTitle = "WS_" & FileName
                FileName &= FileName & ".xls"

                strHeader &= ""
                strHeader &= ""
                strHeader &= " "
                strHeader &= " "

                pg.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", FileName))
                pg.Response.Charset = ""
                pg.Response.Cache.SetCacheability(HttpCacheability.NoCache)

                Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter
                Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)

                htmlWrite.Write(strPrintOut)

                pg.Response.Write(stringWrite.ToString)
                pg.Response.Write(" ")
                pg.Response.End()

            Catch ex As System.Threading.ThreadAbortException

            Catch ex As Exception
                MySession.BC.HandleMessage(ex, pg)
            End Try

        End Sub