TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
phat lee
NA
3
1k
Export searched result to excel in asp.net Mvc.
May 23 2018 5:46 PM
I have a web application where I have some search fields. I need to export the search result to excel sheet. I have tried storing the results in session but that slowed down the whole application. What is the efficient way to do it?
Below is the sample of the codes I tried. Any suggestions, comments, solutions will be highly appreciated. Thank you
public
class
APPET1Controller : Controller
{
private
APContext db =
new
APContext();
// GET: APPET1
public
ActionResult Index(
string
search,
string
cagecode,
string
sortBy,
int
? page,
string
docNumber,
string
remark,
string
status)
{
APPETViewModel viewModel =
new
APPETViewModel();
var aPPET1 = db.APPET1.Include(t =>T.APPETMedia) .Include(t => t.Status) .Include(t => t.APPETCCode) .Include(t => t.APPETDType);
............some more codes..............
DateTime searchDate;
if
(!String.IsNullOrEmpty(search))
{
bool
isDateSearch = DateTime.TryParse(search,
out
searchDate);
if
(isDateSearch)
{
aPPET1 = aPPET1.Where(s => s.Date_Received == searchDate);
}
else
{
aPPET1 = aPPET1.Where(t.Doc_Number.Contains(search)
|| t.Status.Status1.Contains(search)
|| t.Remark.Contains(search)
|| t.CCode.Contains(search));
..............some more codes..............
viewModel.Search = search; } }
var stats = db.Status.Select(s => s.Status1);
viewModel.Statuses =
new
SelectList(stats);
{
if
(!String.IsNullOrEmpty(status))
{
aPPET1 = aPPET1.Where(t => t.Status.Status1.Contains(status));
}
}
if
(!String.IsNullOrEmpty(docNumber))
{
aPPET1 = aPPET1.Where(t => t.Doc_Number.Contains(docNumber));
}
if
(!String.IsNullOrEmpty(remark))
{
aPPET1 = aPPET1.Where(t => t.Remark.Contains(remark));
}
............some more codes.........
Session[
"SearchResults"
] = aPPET.ToList<APPET>();
return
View(viewModel); }
Reply
Answers (
0
)
How to dispaly two web pages in a one webpage in asp.net
Typing Author name Related articlesurl display google search