Warehouse management using Excel and C# - c#

I need basic idea on warehouse management using Excel and C#.
Actually, the warehouse file consist of 30 columns and 40,000 above record.
I need to select only select columns (suppose-12) from the uploaded Excel file (.XLSX)
I need to display 40,000 rows of data (all) with customized columns
Provide user auto search text-boxes (suppose for 5 columns-like truck no, order no, orderdate, wh-name) and display the search result at grid view
Edit and update the data searched by auto search (any row or implement update for all rows)
finally save the data into a new Excel or PDF file
Please help to implement these, using C# and Excel.
I tried but it takes 7-10 mins to save data from datagrid to new Excel file. I have problem with dynamic auto search columns

As a Suggestion: use http://epplus.codeplex.com/ to read the incoming file. Then put all the incoming material in some DataTables.
These DataTables could be used to implement the other functions way easier, since they are build to support that kind of actions.
Save any modified data to these Datatables.
Export them to a new xlsx file, that you can hand back. Agian, you can use epplus

Related

How to select data from database and display in excel - c#

I want to select data from database table and display it on excel sheet.
Basically similar to exporting data to excel, but in my case when Ill open the excel, a select query will be fired which will fetch data from table and display in excel sheet from A1 Cell.
Is this possible? I dont need the code by maybe some idea or reference of how to implement it. I am no expert in c#.
there are many ways you can do this,
it all depends on how you want to manage the logic :
here is a good way to start with :
http://www.c-sharpcorner.com/UploadFile/83fe73/solutions-to-export-data-from-database-to-excel-in-C-Sharp/

Dynamic Excel columns and rows to SQL

I have an Excel template which has dynamic rows and columns (it means the Excel template will be downloaded based on the parameters I select in my UI). Now there will be some data in the Excel sheet against those dynamic rows and columns coming from the database. I want to modify that Excel and import it so that only the updated(modified) cell values are updated in database. I thought a lot and I think this can be done with macros (by changing the color of cells with updated values and picking them up from C#). I would welcome any other thoughts/approaches for this.
An approach I have used is to create a webdav/REST service which can then be mounted as a drive in Windows.
The exposed file on the webdav service was simply a CSV, which users could edit in Excel, but the GET request was serviced by reading the database.
After making the changes, the user saved in Excel, which caused a PUT on the webdav service. The PUT request wrote the new values to the database.

EPPlus / How to get data from pivot table? Or how to manipulate data easily?

I am wasting very much time on manipulating data in reports. Using pivot table is a good idea but how? I tried some free PivotTable classes but they were lacking subtotals.
Then, another approach. For excel output of reports I am using EPPlus. It also supports pivottable. The problem is some of our customers do not have office(OpenOffice, MicrosoftOffice etc.), so just creating and saving an xlsx file does not work. The only thing I can try with EPPlus is creating an ExcelPackage, filling a worksheet with data, and then creating a PivotTable with data.
I have several questions;
1) From that PivotTable object can I access the output of PivotTable fields and values. (Up to now I could not).
2) Related to the above question... Does an xlsx file contains data about the PivotTables or just the rules of creating PivotTable(Like name of table, sourceRange, rowFields, columnFields, dataFields, aggregate options etc). I have made a small test about this. Steps as following:
Opened a new excel file.
Inserted some raw data.
Created pivot table with the data.
Changed some values of data. (without refreshing pivot table)
Saved and closed the file.
Opened the file back.
In fact my guess was "pivot table would update according to new data", but I was wrong. It did not update. This may be a proof for "xlsx file contains not only rules for a pivot table but also all the values of it". If this is so I have a hope to access that data without saving the file (and I do not need any office programs).
3) Any other approach appreciated.
Thanks in advance
I am by no means an expert on EPPlus but have been working with it for the past few months and can hopefully shed some light on your questions.
If you create a brand new xlsx in EEP, add data to a worksheet, create a pivot table pointed at the data/worksheet, and save it - then the PivotTable does NOT contain any data. It merely contains the definition of the how the PT should slice the data when the file is opened in excel (as you mentioned in one of your questions).
When you actually open the file in excel and SAVE IT what excel does is copies all of the data that the PT relies on and puts it in the pivot table cache. This is why you can then delete the original cells that contained the data, save the file, and then reopen it in excel (might have to dismiss some errors), and still see the PT with data. You can even double click on one of the data cells in the PT and excel will regenerate some or all (depending on which cell you clicked) of the associated data into a new sheet.
Yes, your guess was in fact wrong because of this pivot table cache. You have to tell excel to update the data source in the proper Ribbon (assuming the data is still there) to see the new data show up.
So, to access the data you can figure out where it sits by going into the PivotTable.WorkSheet object and pulling the data out from that. You can see how I did it in the extension method i created here:
Create Pivot Table Filters With EPPLUS
Another option would be to extract the actual worksheet.xml file from the xlsx. An xlsx file (and any other MS Office .???x files) are just ZIP files renamed. So you can use the standard .NET methods to get the xml files out of the zip and use something like LinqToXml to extract the data. So something like this:
var zip = new ExcelPackage(file).Package;
var recordspart = zip.GetPart(new Uri("/xl/worksheets/sheet1.xml", UriKind.Relative));
var recordsxml = XDocument.Load(recordspart.GetStream());
It wont be pretty doing all the XML manipulation but if a final format of XLSX will not work it may be your best option.

Dynamically creating populating templated MS Office Excel files using schema, and data, stored in Database

I have an Excel file we consider a template file. Currently, user downloads the file and then manually inputs data into the file column/row by row. What I would want to do however is save this template to a database, and then, on request, dynamically create an excel worksheet using this saved template, and then proceed to populate the columns and rows of the templated excel file with data from other database tables. the following are some of the questions I currently have --
How do I extract the schema for the template from the excel template file?
How do I create an excel file using the extracted template information?
How do I ensure that when I start to populate the created file with data, I start on the right row and column?
How do I solve these please? Any good examples of how this could done, out there?
Also, where is the Microsoft Office SDK download site? I have been searching all day.

have 200 lines in an excel spread sheet and i need to call them in a wp7 app

I have strings (4 columns and 20 rows) in an excel sheet and I need to call there position in an app, such as column 2 row 159.
I was wondering what someone thought about my options and how I would move this data. I have looked into:
plain 2 dimensional array
sqlite
linq
dictionary hash table
It felt like they all required almost all manual data entry which I am trying to avoid. Does anyone have any ideas?
If you just need to take the data in your Excel spreadsheet and make it available to your WP7 application, this should be a straightforward process.
Firstly, I would save it in CSV format, this is the most accessible format for applications to read the data. Add it to your project as a resource and load it within your application, then use a CSV parser to load it into memory. You can then access it directly based on user input.

Categories