-1

The question is brief because I don't exactly know how to start approaching the problem to understand it. I have identified the .aspx file (in my C# web app project) where an export picture is located, when pressing on it an .xlsx can be downloaded (with content taken from the database), where do you suggest to start the investigation to understand just HOW this file is generated? - I'm interested in the SQL query that is executed to populate the excel.

You may think of it in another way, if this was given you as a task, how would you sketch a plan to generate an excel from a C# web app project based on an SQL query that populates Sheet1?

PS it's not a macro file. Thank you for any pointers.

Janine
  • 293
  • 3
  • 6
  • 13
  • 1
    I think its better you can use EPPlus excel package library for export excel.See http://epplus.codeplex.com/ – temUser Sep 10 '15 at 10:55

2 Answers2

0

Just don't use the excel COM for a webapp. Instead check out Epplus or maybe the Apache POI project has something that works with .NET for generating excel files.

Basically you'll just run your database query, put the data in the worksheet w/ your formatting etc, then send it off to the client. You could stream it out or post it somewhere for download later.

You have lots of options just need to break this down into parts.

Shawn K
  • 779
  • 5
  • 13
0

To answer the initial question "where do you suggest to start the investigation to understand just HOW this file is generated?":

Investigate the export picture with your browser tooling, for instance in Chrome you can do a inspect element from the context menu when you right click on the image. Some possibilities:

  • A form is submitted ASP.Net style, find the function it is calling on the target ASPX/ASHX page. Set a breakpoint in that function, hit it, follow the code.
  • Javascript code is run, probably doing a JSON call to a service MVC/WebAPI function. Set a breakpoint in that function, hit it, follow the code.
  • Still can't find it, search for the word ContentDisposition in the code, this is needed 99% of the times to send files to the client browser as an attachment.
Michel van Engelen
  • 2,791
  • 2
  • 29
  • 45