Home > Net >  Have any aspnet export excel code
Have any aspnet export excel code

Time:11-20

Which great god to give directions, thank you

CodePudding user response:

You ask is not as good as baidu search directly to https://www.baidu.com/s? Wd=asp.net E5 BC AF E5 % % % % % 87% BAexcel& Rsv_spt=1 & amp; Rsv_iqid=0 xf038f96c0003d5c1 & amp; Issp=1 & amp; F=8 & amp; Rsv_bp=1 & amp; Rsv_idx=2 & amp; Ie=utf-8 & amp; Tn=78040160 _14_pg & amp; Ch=8 & amp; Rsv_enter=1 & amp; Rsv_dl=tb& Rsv_sug3=18 & amp; Rsv_sug1=3 & amp; Rsv_sug7=100 & amp; Rsv_t=d618zc7H % 2 blbpwmsoove9mjd2%2 fh % 2 bfltxrm5snkl05t30%2 bjsh9z3iu % 2 bvy8t875auhlfb0qmba & amp; Rsv_sug2=0 & amp; InputT=7206 & amp; Rsv_sug4=7207

Or search NPOI

CodePudding user response:

Your problem is divided into two parts, 1, generate EXCEL, 2, download,

CodePudding user response:

Npoi spire. XLS
Understand, very simple, a pile of demo online

CodePudding user response:

https://bbs.csdn.net/topics/390830774

This is I had sent before post.

The following is my download post


https://download.csdn.net/download/diaodiaop/7611721

CodePudding user response:

Using NPOI!

CodePudding user response:

Imports System. Collections
Imports ponentModel System.Com
Imports System. Data
Imports System. Drawing
Imports System. Web
Imports System. Web. SessionState
Imports System. Web. UI
Imports System. Web. UI. WebControls
Imports System. Web. UI. HtmlControls
Imports System. Data. The OleDb
Imports System. The Data. SqlClient

Imports System. IO
Imports System. The Configuration
Imports System. Security. Permissions. FileDialogPermission
Imports System. Diagnostics
Public Class rep_jd
Inherits System. Web. UI. Page

# Region "Web forms designer generated code", "

'the call is necessary to the Web forms designer,

End Sub
Protected WithEvents Tbyear the As System. Web. UI. WebControls. TextBox
Protected WithEvents Ddlpart the As System. Web. UI. WebControls. DropDownList
Protected WithEvents Ddl As System. Web. UI. WebControls. DropDownList
Protected WithEvents bt2 the As System. Web. UI. WebControls. The Button
Protected WithEvents lblstatus the As System. Web. UI. WebControls. Label

'note: the following placeholder statement is essential for Web forms designer,
'don't delete or move it,
Private designerPlaceholderDeclaration the As System. The Object

Private Sub Page_Init (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles MyBase. The Init
'CODEGEN: this method calls are necessary to Web forms designer
'don't use the code editor to modify it,
InitializeComponent ()
End Sub

# End Region

Dim cn As New SqlConnection (ConfigurationSettings. AppSettings (" conn "))
Private Sub Page_Load (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles MyBase. Load
'place to initialize the page the user code here
Dim ss, uname, s4 As String
Dim unid, I As an Integer


If the Session (" userid ") Is Nothing Then

RegisterClientScriptBlock (hint: ", "" & lt; Script language=javascript> Alert (' timeout, please login again! ') & lt;/script>" )
The Exit Sub
The Else

If Not IsPostBack Then

Tbyear. Text=DateTime. Now. The Year ()

I=CInt (DateTime. Now. The Month)
If I & gt; 0 And I & lt; 7 Then=
In the first half of Ddlpart. SelectedValue="https://bbs.csdn.net/topics/"
The Else
Ddlpart. SelectedValue=second half of the "https://bbs.csdn.net/topics/"
End the If

End the If
End the If

End Sub

Private Sub bt2_Click (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles bt2. Click
Dim ss, uname, s4 As String
Dim unid As Integer

Dim ds As New DataSet
Dim sy As String
Dim I, j As Integer
Dim fname As String="fname"

Dim beforetime, aftertime As DateTime


Beforetime=DateTime. Now 'add 2015
Dim xlApp As New Excel. Application
Aftertime=DateTime. Now 'add 2015
Dim xlBooks As Excel Workbooks, xlBook As Excel. The Workbook

Dim xlSheet As Excel. The Worksheet


Dim spath As String

Spath=Server. MapPath ("./")
Spath=spath & amp; "Uploads \ pingwei4. XLS"

XlApp. Visible=False
'xlBook=xlApp. Workbooks (). The Add

XlApp. DisplayAlerts=False
XlBooks=xlApp. Workbooks
XlBooks. Open (spath)
XlBook=xlBooks. Item (1)
'xlBook=xlApp. Application. Workbooks. Open (" TAB. The XLT, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing)
XlSheet=xlBook. Worksheets (" sheet1 ")

Dim Table As New DataTable
During sy=DateTime. Now.


I=0

Try

Ss="select the unit, name, gid, pos, zhicheng, thisyear, partyear, huanjie, fenzu from pingwei where thisyear='
"Ss=ss & amp; Sy & amp; "' and partyear=" & amp; Ddlpart. SelectedValue. Trim & amp; "'
"Ss=ss & amp; "And huanjie='" & amp; Ddl. SelectedValue. Trim & amp; "' order by fenzu, unit", "


Ds. Tables. The Clear ()


Ds=Funlib. MyQueryUsesqlDataSet (ss, "temp")
If ds. Tables (" temp "). The Rows. Count & gt; 0 Then
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related