|
I'm from austria and somehow the characters particulat to the german language get lost in the conversion.
"Ä" shows up as a garbled mess of characters.
What can I do to make it convert correctly?
Thanks!
|
|
|
|
|
Just realized that theres a new version available that lets you provide a charset.
But
Now it can't serialize or deserialize my typed datatable, whats up with that?
|
|
|
|
|
Philipp Lenz wrote:
Now it can't serialize or deserialize my typed datatable, whats up with that?
I'm getting the same thing. Anyone have a solution?
|
|
|
|
|
it does depend on the client having excel application, otherwise no export could be done to excel.
Goitom Tesfaye
|
|
|
|
|
Hi,
I've just tried the Export Button control but faced with a problem. After clicking the button, the error "This File is not in a recognizable format" pops up. After clicking OK, the Excel workbook opens normally. Here is my code extract from Page_Load:
Dim dv As DataView
dv = CreateDataSource()
btnExcel.Dataview = dv
btnExcel.FileNameToExport = "test2.xls"
btnExcel.ExportType = PNayak.Web.UI.WebControls.ExportButton.ExportTypeEnum.Excel
btnExcel.Separator = PNayak.Web.UI.WebControls.ExportButton.SeparatorTypeEnum.TAB
Is it a bug or I was doing something wrong? Just in case, I've tried other ExportTypes and Separators - CSV and Comma - with the same result: the same error message appears followed by opening Excel.
Thanks.
|
|
|
|
|
If you are not needing the unicode extended characters, you can fix this by changing the following code in his customExport subroutine:
' Dim Encoding As New System.Text.UnicodeEncoding
Dim Encoding As New System.Text.ASCIIEncoding
The Unicode file needs the hex characters FF and FE as the first 2 characters. Microsoft recommends adding a ' through Notepad at the beginning of the file. The real result is that Notepad adds the FF FE characters at the beginning of the file.
ge
|
|
|
|
|
Thanks for your suggestion and clarification. Is there any fix if the extended characters are still needed?
|
|
|
|
|
Add the following two rows:
<br />
Dim unicodeBytes As Byte() = {255, 254}<br />
response.BinaryWrite(unicodeBytes)<br />
response.BinaryWrite(uEncoding.GetBytes(_exportContent))<br />
You might have to add 2 to the content length also:
<br />
Dim length As Integer = 2 + uEncoding.GetByteCount(_exportContent) 'FF FE <br />
response.AddHeader(C_HTTP_CONTENT_LENGTH, length.ToString())<br />
--------------------
No one is perfect.
Welll, there was this guy... but we killed him.
|
|
|
|
|
so the entire codes are
Private Sub CustomExport()
Dim response As System.Web.HttpResponse = System.Web.HttpContext.Current.Response
response.Clear()
' Add the header that specifies the default filename
' for the Download/SaveAs dialog
response.AddHeader(C_HTTP_HEADER_CONTENT, C_HTTP_ATTACHMENT & FileNameToExport)
' Specify that the response is a stream that cannot be read _
' by the client and must be downloaded
If ExportType = ExportTypeEnum.CSV Then
response.ContentType = C_HTTP_CONTENT_TYPE_OCTET
Else
response.ContentType = C_HTTP_CONTENT_TYPE_EXCEL
End If
Dim _exportContent As String = String.Empty
_exportData = [Dataview]
If (Not _exportData Is Nothing) AndAlso _exportData.Table.Rows.Count > 0 Then
If Separator = SeparatorTypeEnum.TAB Then
_exportContent = ConvertDataViewToString(_exportData, Delimiter, vbTab)
Else
_exportContent = ConvertDataViewToString(_exportData, Delimiter, ",")
End If
End If
If _exportContent.Length <= 0 Then
_exportContent = C_ERROR_NO_RESULT
End If
response.Charset = CharSet
Dim Encoding As New System.Text.UnicodeEncoding
'Added
Dim length As Integer = 2 + Encoding.GetByteCount(_exportContent) 'FF FE
response.AddHeader(C_HTTP_CONTENT_LENGTH, length.ToString())
Dim unicodeBytes As Byte() = {255, 254}
response.BinaryWrite(unicodeBytes)
response.BinaryWrite(Encoding.GetBytes(_exportContent))
' Stop execution of the current page
response.End()
End Sub
End Class
Thank you very much for every kindly comments
|
|
|
|
|
Hi,
I am using Dreamweaver and trying to use this code of yours to export records to TXT files. I put in the code for the button, and when I run the aspx page, I can click on the button to export the data, and it succesfully creates a file. However, the file either says "No Data Found", in the case of excel, or has a few characters of gibberish (if it's CSV).
I guess my problem is that there is no dataset, even though the page has a datagrid properly displayed on it. I guess I need populate a dataset for export from the datagrid on the page, but I'm not sure how to do this. You explanation on this page doesn't help me much, as I'm a newbie to ASPX coding, so extra explanation may be needed.
What is necessary, on an ASPX page, to run this properly? I'd like to do it all "in-page" without referencing an external VB code module as you do in your example. Here is my page's code:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<%@ Register TagPrefix="pnwc" Namespace="PNayak.Web.UI.WebControls" Assembly="PNayak.Web.UI.WebControls.ExportButton" %>
<mm:dataset
id="ds_Campaign_Master"
runat="Server"
isstoredprocedure="false"
connectionstring="<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_ThermoDBConnection") %>"
databasetype="<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_ThermoDBConnection") %>"
commandtext="<%# "SELECT * FROM Campaign_Master" %>"
debug="true"
="">
<mm:pagebind runat="server" postbackbind="true">
<title>Campaign List
<asp:datagrid id="dg_Campaign_Master"
="" runat="server" allowsorting="False" autogeneratecolumns="false" cellpadding="3" cellspacing="0" showfooter="false" showheader="true" datasource="<%# ds_Campaign_Master.DefaultView %>" allowpaging="false">
<headerstyle horizontalalign="center" backcolor="#E8EBFD" forecolor="#3D3DB6" font-name="Verdana, Arial, Helvetica, sans-serif" font-bold="true" font-size="smaller">
<itemstyle backcolor="#F2F2F2" font-name="Verdana, Arial, Helvetica, sans-serif" font-size="smaller">
<alternatingitemstyle backcolor="#E5E5E5" font-name="Verdana, Arial, Helvetica, sans-serif" font-size="smaller">
<footerstyle horizontalalign="center" backcolor="#E8EBFD" forecolor="#3D3DB6" font-name="Verdana, Arial, Helvetica, sans-serif" font-bold="true" font-size="smaller">
<pagerstyle backcolor="white" font-name="Verdana, Arial, Helvetica, sans-serif" font-size="smaller">
<columns> <asp:hyperlinkcolumn
="" headertext="Campaign" visible="True" datatextfield="Campaign" datanavigateurlfield="CampaignID" datanavigateurlformatstring="flightchooser.aspx?CampaignID={0}">
<asp:boundcolumn datafield="Location"
="" headertext="Location" readonly="true" visible="True">
<asp:boundcolumn datafield="Season"
="" headertext="Season" readonly="true" visible="True">
<asp:boundcolumn datafield="First_Launch"
="" headertext="First Launch" readonly="true" visible="True" dataformatstring="{0:MMMM dd, yyyy}">
<asp:boundcolumn datafield="Last_Launch"
="" headertext="Last Launch" readonly="true" visible="True" dataformatstring="{0:MMMM dd, yyyy}">
<pnwc:exportbutton id="btnCSV" runat="server"
="" separator="TAB" text="Export to CSV" filenametoexport="Campaign_Master.txt" backcolor="#E0E0E0">
<pnwc:exportbutton id="btnExcel" runat="server"
="" separator="TAB" text="Export to Excel" filenametoexport="Books.xls" backcolor="#E0E0E0">
What else do I need to export properly?
Thanks for your time,
Eric
|
|
|
|
|
If I add the page_load code without the button properties as:
Private Sub Page_Load(ByVal sender As System.Object,_
ByVal e As System.EventArgs) Handles MyBase.Load
Dim ds as dataset=filldataset()
dgBooks.DataSource = ds.Tables("Books")
dgBooks.DataBind()
End Sub
I get an error saying "filldataset" not defined...
Is there another command for filldataset?
|
|
|
|
|
Hi.
I am trying to set the filename of the exported table at run-time, but without success. If I set the filename at design-time, the download window shows me the correct name. But if I try to set the filename at page_load, with this code:
exDownload.FileName = DateTime.Now.ToShortDateString & "_Results.xls"
the download window shows me the name of the page as the filename. I am using the first version of the dll. Can anyone help me?
Thanks.
|
|
|
|
|
I have implemented something similar so this may or may not help out. One difference to note is that I am not setting the .FileName propertying during the Page_Load. I am setting it during the _Click event of one of my page buttons because of some dynamics specific to how my page works.
I looked at the .ToShortDateString method as well, but it includes such things as the day of the week, etc, that could yield some unpredictable results and could cause an invalid filename. I decided instead to go with the .Ticks property since it is guaranteed to be an unformatted string of numbers.
btnExcel.FileNameToExport = "ExcelExport" + System.DateTime.Now.Ticks.ToString() + ".xls";
|
|
|
|
|
This freeware is great,
However I am having trouble getting it to work in my own project. (sorry I am new to .NET)
I have copied over the PNayak.Web.UI.WebControls.ExportButton.dll and PNayak.Web.UI.WebControls.ExportButton.xml into my bin dir, then made a reference to
PNayak.Web.UI.WebControls.ExportButton.
On my aspx page I have:
included the exportbutton control and the IDE generates the code
Protected WithEvents lnkbtnExcel As PNayak.Web.UI.WebControls.ExportLinkButton
which is seems to be unhappy with. The message being
'The base class includes the field 'lnkbtnExcel', but its type (BEAN2.PNayak.Web.UI.WebControls.ExportLinkButton) is not compatible with the type of control (PNayak.Web.UI.WebControls.ExportLinkButton).'
If I comment out the
Any ideas? I've really spent ages trying to figure this out and have had no luck!
|
|
|
|
|
|
As i dive into the code, I see that there wasn't any implementation to handle commas (text fields in general) or tabs embedded in the text. It would be nice if we could have that, since that trips excel when fields that contain commas are not quoted (")
Freddy
|
|
|
|
|
It seems to be failing on the line
MyBase.New (line 38). Here is what I did thus far:
1) created a folder called testExport
2) unzipped your demo zip file to that folder. Thus it created two folders within testExport - "TestMyControls" and "PNWebControls".
3) I added a virtual directory in IIS under root as "testExport"
4) I loaded the following URL:
http://machinename/testExport/TestMyControls
5) It gave the error as displayed above.
Please help.
Thanks,
|
|
|
|
|
I added the control to a form which has a DataSet, cached in a session variable. This is a large dataset. When I set the export buttons' dataview to this dataset my page took an age to load, and the state variable was massive. I changed the view state of the button control to false, but when the button is clicked the resulting file simply contains "No data found".
I tried connecting the dataset in the button click event but this did not affect the result, still "No data found".
If Not Page.IsPostBack Then<br />
If (Session("EventData") Is Nothing Or Request("refresh") = "1") Then<br />
' get the dataset from the database<br />
Dim myConn As OleDbConnection<br />
<br />
Const strConn = "Provider=msdaora;Data Source=cognos;User Id=csiread;Password=******"<br />
Const strDate = "01-Jan-2004"<br />
Const strSQL = "select CSIREAD.SORD.ORD_NBR, CSIREAD.SORD.DT_LST_UPDATE, CSIREAD.PART.USER_FIELD_1, CSIREAD.PART.USER_FIELD_2, RTRIM(CSIREAD.RMAD.ITEM_PART_NBR), CSIREAD.PART.FAMILY_PART_NBR, RTRIM(CSIREAD.RMAM.CUST_ID), CSIREAD.SORD.QTY_ORDERED, CSIREAD.RMAD.DT_RECEIVED, CSIREAD.SORD.ORD_ITM_STATUS, CSIREAD.RMAD.CTRT_TA_DATE, CSIREAD.SHPD.DT_CREATED, CSIREAD.SHPD.PICK_DT, CSIREAD.SHPD.PK_PICK_DT, CSIREAD.SORD.TOT_ITM_AMT*(CSIREAD.OAS_CURLIST.RATE/10000000) from CSIREAD.SORD, CSIREAD.PART, CSIREAD.LCAL, CSIREAD.SCRM, CSIREAD.OAS_CURLIST, CSIREAD.RMAD, CSIREAD.RMAM, CSIREAD.ORGM, CSIREAD.SHPD where CSIREAD.SORD.REC_CD='DT' and CSIREAD.SORD.DT_CREATED=CSIREAD.LCAL.GREGORIAN_DATE and not CSIREAD.SORD.ORD_NBR is null and CSIREAD.SORD.ORD_NBR=CSIREAD.RMAD.RMA_NBR and CSIREAD.SORD.DT_LST_UPDATE>'01-JAN-2004' and CSIREAD.OAS_CURLIST.CMPCODE=CSIREAD.ORGM.ORG_ID and CSIREAD.SCRM.RECORD_KEY='SCTM' and CSIREAD.OAS_CURLIST.CMPCODE=CSIREAD.SCRM.CHR_AE_003 and CSIREAD.RMAD.LN_NBR=1 and CSIREAD.RMAD.RMA_NBR=CSIREAD.RMAM.RMA_NBR and CSIREAD.RMAD.ITEM_PART_NBR=CSIREAD.PART.PART_NBR and CSIREAD.OAS_CURLIST.LSTSEQNO=1 and CSIREAD.RMAM.CURRENCY_CD=CSIREAD.OAS_CURLIST.CURCODE and CSIREAD.SORD.ORD_NBR=CSIREAD.SHPD.ORD_NBR(+) and CSIREAD.SORD.LN_NBR=CSIREAD.SHPD.LN_NBR(+)"<br />
<br />
Dim myDA = New OleDbDataAdapter(strSQL, strConn)<br />
<br />
myDA.fill(myDS)<br />
' save the dataset to a session variable<br />
Session("mySet") = myDS<br />
End If<br />
' bind the datagrid to the session variable, not the dataset!<br />
DataGrid2.DataSource = Session("mySet").tables(0)<br />
DataBind()<br />
End If<br />
End Sub<br />
<br />
Private Sub DataGrid1_Paging(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs) Handles DataGrid2.PageIndexChanged<br />
' switch to new page <br />
DataGrid2.CurrentPageIndex = e.NewPageIndex<br />
DataGrid2.DataSource = Session("mySet").tables(0)<br />
DataBind()<br />
End Sub<br />
<br />
Private Sub DataGrid1_Sort(ByVal sender As Object, ByVal e As DataGridSortCommandEventArgs) Handles DataGrid2.SortCommand<br />
myDS = Session("mySet")<br />
myDS.Tables(0).DefaultView.Sort = e.SortExpression<br />
Session("mySet") = myDS<br />
DataGrid2.DataSource = Session("mySet").tables(0)<br />
DataBind()<br />
End Sub
Is it possible to use this control to download a large dataset to an Excel file (say 15,000 lines)?
|
|
|
|
|
Yeah, this EXPORT method seems to do a horrible job with large datasets. I can get it to work fine with smaller sets, but at some point, I get nothing but HTTP timeout responses when I try to export large datasets. Even a recordset that is 515 lines seems to cause time outs! I guess I might need to look elsewhere unless the developer starts helping us out here.
Some optimization please?
|
|
|
|
|
I had received this reply from the author; I hadn't realised the response wasn't posted on here, and I'm sure its relevant for others, so here it is:
This contol uses Viewstate for the data to be persisted on postbacks and therefore by nature viewstate put heavy load on page.<br />
<br />
I suggest you may extract code from the button and stick in a new ASPX page and use Server.Transfer instead of using my button.<br />
<br />
Sorry! I gues this will be shortcomings of my solution.<br />
<br />
Thanks for your feedback!
I'm using Orilogic Export.NET; this works fine and doesn't cost much, a few dollars.
|
|
|
|
|
I'm trying to export one table to three files by clik a export button and there should be no prompt for save as. How can I do that?
|
|
|
|
|
Open the .xls by ignoring the err , save it again. The old excel will ignore
<tab> control character . It still work for the .xls file.
|
|
|
|
|
Hi,
Very nice component, but....I would like to use it in a win-form project, so I started to manually 'convert' it from web to winforms. The problem is that you use 'viewstate' but this is not a member of System.Windows.Forms. So any idea how i can bypass this issue.
thnx
Geert D.
|
|
|
|
|
Well... I haven't looked at this code, but in general, viewstate is just a way to save object state between postbacks - similar to using the session object, without the load in the server(it's saved in a hidden form field, so the load is pushed to the client) - so it's scope is the whole form being rendered, and there is one instance for each rendered output of the form.
In a winform project a form level variable would be roughly similar - but you might be able to restrict the scope further. Just figure out the correct scope and context for the data that's being saved, and store it.
-MB
|
|
|
|
|
Thnx Mark,
>> Just figure out the correct scope and context for the data that's being saved, and store it.
This is probably a stupid question, but what do you mean with "...and context..." and furthermore wich kind of variable do I use (dataset / datatable/ ?)
greetz
Geert
|
|
|
|
|