Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6576685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:32:34+00:00 2026-05-25T15:32:34+00:00

Hi all I’m using Open XML and ExtremML to generate an Excel File on

  • 0

Hi all I’m using Open XML and ExtremML to generate an Excel File on the Server and Download it, but when you I try to open it it gives me the error “EXCEL FOUND UNREADABLE CONTENT. DO YOU WANT TO RECOVER THE CONTENTS OF THIS WORKBOOK?
IF YOU TRUST THE SOURCE OF THIS WORKBOOK, CLICK YES”, so checking on the file inside y found it’s adding a tag named company, that when i remove it it corrects the error that Excel is giving, It’s in VB .NET, this is my code:

Protected Sub btnExcel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExcel.Click
  Dim iProcess As String = ""
  Dim loOraClientDb As clsOraClientDb = New clsOraClientDb
  Dim vFilename As String = ""
  Try
     Try
        iProcess = "btnExcel_Click 1"
        Dim ExcelSendInfo As DataTable = Session("dtExcel")
        Dim ExcelExportedInfo As DataTable = New DataTable
        Dim PkgOutValues() As String = {}
        Dim ExcelDataSet As DataSet = New DataSet
        Dim vtablename As String = ""
        Dim vtabletoname As String = ""
        Dim WFT As New WebFileTools
        If chkFLayout.Checked Then
           iProcess = "btnExcel_Click 2"
           Dim sDNS As StringBuilder = New StringBuilder()
           If Not chkFInfo.Checked Then
              For Each dr In ExcelSendInfo.Rows
                 sDNS.AppendLine(dr(0))
              Next
           End If

           iProcess = "btnExcel_Click 3"
           If Not loOraClientDb.Open(ConnectionStrings("DatabaseSDSTP6301").ConnectionString) Then
              EnableErrorByState(loOraClientDb.Message & ", Process: " & iProcess)
              Exit Sub
           Else
              iProcess = "btnExcel_Click 4"
              Dim vStatus As String
              If ViewState("CurrentWindow") = "Report" Then
                 vStatus = "G.G_STATUSID!=2"
              Else
                 vStatus = "G.G_STATUSID=2"
              End If

              iProcess = "btnExcel_Click 5"
              Dim PkgInParameters(6)() As String
              PkgInParameters(0) = New String() {"VEXPORTEDDNS", "VARCHAR2", "Empty", sDNS.ToString.Replace(Chr(13) & Chr(10), ",")}
              PkgInParameters(1) = New String() {"VSTATUS", "VARCHAR2", "Empty", vStatus}
              PkgInParameters(2) = New String() {"chkFInfo", "VARCHAR2", "Empty", BoolToStr(chkFInfo.Checked)}
              PkgInParameters(3) = New String() {"VSEARCHOPS", "VARCHAR2", "Empty", DDLSearchOps.SelectedValue}
              PkgInParameters(4) = New String() {"VSEARCH", "VARCHAR2", "Empty", txtsearch.Text}
              PkgInParameters(5) = New String() {"VRANGE1", "VARCHAR2", "Empty", txtrange1.Text}
              PkgInParameters(6) = New String() {"VRANGE2", "VARCHAR2", "Empty", txtrange2.Text}
              Dim PkgReturnParameters() As String
              PkgReturnParameters = New String() {"VRETURN", "CURSOR", "Empty"}
              Dim PkgOutParameters(0)() As String
              PkgOutParameters(0) = New String() {"VTOTPROJS", "NUMBER", "Empty"}

              iProcess = "btnExcel_Click 6"
              If Not loOraClientDb.ExecuteProcedureFunction("PKG_GENERALINFO.GENERATEEXCEL", PkgInParameters, _
                                                      PkgOutParameters, PkgReturnParameters, , ExcelExportedInfo, _
                                                      , PkgOutValues) Then
                 EnableErrorByState(loOraClientDb.Message & ", Process: " & iProcess)
                 Exit Sub
              End If
              vtablename = "MAININFO"
              vtabletoname = "MAINTABLE"
           End If
        Else
           iProcess = "btnExcel_Click 7"
           ExcelExportedInfo = ExcelSendInfo
           vtablename = "TIMEREP"
           vtabletoname = "TIMEREPORT"
        End If

        ExcelDataSet.Tables.Add(ExcelExportedInfo)
        ExcelDataSet.Tables(0).TableName = vtablename
        Dim vFileTemplate As String = ""
        Dim RandomNumber As New Random()
        If vtablename = "MAININFO" Then
           vFileTemplate = "FullLayout.xlsx"
           vFilename = "FullLayout" & RandomNumber.Next(1000).ToString & ".xlsx"
        Else
           vFileTemplate = "TimeReport.xlsx"
           vFilename = "TimeReport" & RandomNumber.Next(1000).ToString & ".xlsx"
        End If
        Session("vfilename") = vFilename
        WFT.CopyServerFile("ExcelTemplates\" & vFileTemplate, "ExcelTemplates\" & vFilename, True)
        Using DPSExcelTemplate = ExcelOpenPackage(Server.MapPath(".") & "\ExcelTemplates", vFilename.Replace(".xlsx", ""))
           ExcelWorkBookPopulateDS2Table(DPSExcelTemplate, ExcelDataSet, vtablename, vtabletoname)
        End Using
        Server.ClearError()
        Response.Redirect("DownloadPage.aspx", False)
        iProcess = "btnExcel_Click 28"
     Catch ex As Exception
        EnableErrorByState(ex.Message & ", Process: " & iProcess)
        If File.Exists(Server.MapPath(".") & "\ExcelTemplates\" & vFilename) = True Then
           File.Delete(Server.MapPath(".") & "\ExcelTemplates\" & vFilename)
        End If
     End Try
  Finally
     loOraClientDb.Close()
     ShowCorrespondingWindows()
  End Try
End Sub

The page DownloadPage.aspx has this code:

Imports WebFileTools
Imports System.IO

Partial Class DownloadPage
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  Dim vfilename = Session("vfilename").ToString
  Dim nfilename = ""
  If vfilename.IndexOf("FullLayout") <> -1 Then
     nfilename = "FullLayout_" & Today.ToShortDateString
  Else
     nfilename = "TimeReport_" & Today.ToShortDateString
  End If
  Dim WFT As New WebFileTools
  WFT.DownloadServerFile("ExcelTemplates\" & vfilename, MIMEType.Excel2007, nfilename)
End Sub
End Class

I can’t seem to find the problem has anyone gotten this error or knows how to fix this problem?

I Forgot to add this code thats for generating the Excel file with ExtremMl:

Public Shared Function ExcelOpenPackage(ByVal ServerPath As String, _
                                            ByVal ExcelFileName As String) As ExtremeML.Packaging.SpreadsheetDocumentWrapper
        Dim ExcelPackage = SpreadsheetDocumentWrapper.Open(ServerPath & "\" & ExcelFileName & ".xlsx")
        Return ExcelPackage
    End Function

And this is to fill the info on the file:

Public Shared Sub ExcelWorkBookPopulateDS2Table(ByRef ExcelPackage As ExtremeML.Packaging.SpreadsheetDocumentWrapper, _
                                                    ByRef Data As DataSet, _
                                                    ByVal DataTableName As String, _
                                                    ByVal ExcelTableName As String)
        Dim ExcelTable = ExcelPackage.WorkbookPart.GetTablePart(ExcelTableName).Table
        ExcelTable.Fill(Data, DataTableName)
    End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:32:34+00:00Added an answer on May 25, 2026 at 3:32 pm

    I don’t know exactly why but the problem was with my Download code previusly it was like this:

    Public Sub DownloadServerFile(ByVal FileToDownload As String, ByVal MIMETYPE As MIMEType,   Optional ByVal NewNameOfFileToDownload As String = "")
      Dim FileExt As String = ""
      Dim F2DArr As String = Path.GetFileName(FileToDownload)
    
      Current.Response.ClearContent()
      Current.Response.ClearHeaders()
    
      Select Case MIMETYPE
         Case WebFileTools.MIMEType.Excel2007
            Current.Response.ContentType = _
                    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
            FileExt = ".xlsx"
         Case WebFileTools.MIMEType.Word2007
            Current.Response.ContentType = _
                    "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
            FileExt = ".docx"
         Case WebFileTools.MIMEType.PowerPoint2007
            Current.Response.ContentType = _
                    "application/vnd.openxmlformats-officedocument.presentationml.presentation"
            FileExt = ".pptx"
      End Select
    
      If NewNameOfFileToDownload.Trim.Length > 0 Then
         Current.Response.AppendHeader("content-disposition", "inline;attachment;filename=" _
                               & NewNameOfFileToDownload & FileExt)
      Else
         Current.Response.AppendHeader("content-disposition", "inline;attachment;filename=" & F2DArr)
      End If
    
      Current.Response.Clear()
      Current.Response.TransmitFile(Server.MapPath(".") & "\" & FileToDownload)
      Current.Response.Flush()
      If File.Exists(Server.MapPath(".") & "\" & FileToDownload) = True Then
         File.Delete(Server.MapPath(".") & "\" & FileToDownload)
      End If
      Current.ApplicationInstance.CompleteRequest()
    End Sub
    

    Now i changed this line Current.ApplicationInstance.CompleteRequest() for Current.Response.End() and the file gets downloaded correclty

    and now i cant call my download code directly:

    Server.ClearError()
            WFT.DownloadServerFile("ExcelTemplates\" & vFilename, MIMEType.Excel2007, nfilename)
            iProcess = "btnExcel_Click 28"
         Catch ex As Exception
            EnableErrorByState(ex.Message & ", Process: " & iProcess)
            If File.Exists(Server.MapPath(".") & "\ExcelTemplates\" & vFilename) = True Then
               File.Delete(Server.MapPath(".") & "\ExcelTemplates\" & vFilename)
            End If
         End Try
      Finally
         loOraClientDb.Close()
         ShowCorrespondingWindows()
      End Try
    

    It’s not suposed to be the correct way of using Response.End, because it always trows an error but I don’t now if this is the correct way of using Current.ApplicationInstance.CompleteRequest() or that Response.End does something that CompleteRequest is not doing in order for it to get the correct MIME Type

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I have a stored procedure on SQL Server 2005 that accepts an XML
All the recent VisualSVN Server posts made me want to check it out. I
All I know about the constraint is it's name ( SYS_C003415 ), but I
All throughout an application wherever error messages (or other user messages) are used I
All time am getting below error message in groovy... Could not understand whats causing
all. I've got two domains set up under apache on a single server (Linux).
all, I am trying to multiply a matrix to a vector in OpenGL, but
All the examples I can find using DLLImport to call C++ code from C#
All APIs in Hibernate are from 1.4 and are thus not using java generics.
All, I am using the JQuery Autocomplete Plugin 1.0.2 in a JQuery UI Dialog.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.