2014-12-25 3 views
0

У меня есть отчет о кристалле на моем веб-сайте ASP.NET, и он успешно отображается, но он не может быть экспортирован в Microsoft Access. Операционная система клиента - 32 бит Windows 8. Вот ошибка, которая возникает: enter image description hereПреобразование отчетов Crystal Reports в PDF или Microsoft Excel

Я бы очень излечил любые предложения. Заранее спасибо.

+0

Вы были в состоянии решить эту проблему с предложением, приведенным ниже? –

ответ

0

сначала нужно добавить кнопки радио следующим образом:

 <tr> 
      <td> 
      </td> 
      <td> 
      <asp:RadioButtonList ID="rblFormat" runat="server" RepeatDirection="Horizontal" CssClass="Profiletitletxt"> 
      <asp:ListItem Text="PDF" Value="1" Selected="True"></asp:ListItem> 
      <asp:ListItem Text="MS Word" Value="2"></asp:ListItem> 
      <asp:ListItem Text="MS Excel" Value="3"></asp:ListItem> 
      </asp:RadioButtonList> 

      </td> 
      <td> 
      </td> 
      </tr> 

в коде в отчете связывания добавить:

  If rblFormat.SelectedValue = 1 Then 
       cryRpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, True, "ExportedReport") 
      ElseIf rblFormat.SelectedValue = 2 Then 
       cryRpt.ExportToHttpResponse(ExportFormatType.WordForWindows, Response, True, "ExportedReport") 
      ElseIf rblFormat.SelectedValue = 3 Then 
      ExportDataSetToExcel(DT, "ExportedReport") 
      End If 

Для Excel добавить:

 Public Shared Sub ExportDataSetToExcel(ByVal ds As DataTable, ByVal filename As String) 
     Dim response As HttpResponse = HttpContext.Current.Response 
     response.Clear() 
     response.Buffer = True 
     response.Charset = "" 
     response.ContentType = "application/vnd.ms-excel" 
      Using sw As New StringWriter() 
      Using htw As New HtmlTextWriter(sw) 
       Dim dg As New DataGrid() 
       dg.DataSource = ds 
       dg.DataBind() 
       dg.RenderControl(htw) 
       response.Charset = "UTF-8" 
       response.ContentEncoding = System.Text.Encoding.UTF8 
       response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble()) 
       response.Output.Write(sw.ToString()) 
       response.[End]() 
      End Using 
     End Using 
    End Sub