3
Answers

ASP.NET MVC - How to update and upload complex Excel file

Photo of mike idowu

mike idowu

7y
188
1
I have this Excel File which I tried to upload. It has Parent Category
 
 
 
Model
 public partial class CategoryLevel 
{ 
public long CategoryID { get; set; } 
public string CategoryName { get; set; } 
public string OPTION_VALUE { get; set; } 
public Nullable<int> ParentID { get; set; } 
public Nullable<int> ParentID1 { get; set; } 
public Nullable<int> ParentID2 { get; set; }
 
Data sample
 
 
Controller
The code ihave written so far is in the controller.
 

Without clicking twice to upload, it will retrieve the data it has saved to perform the following manipluations.

  1. From the Excel, Where Category Code is equal to Parent Category, it means its a child of the corresponding parent. So, it will save the CategoryID of its parent as its ParentID
  2. From the Excel, where Category Name is Null, it means its a root and has no parent
  3. ParentID1 is the Level - It can get to level N
  4. ParentID of the Root Category(Level 1) will be set to 0
  5. ParentID of the Child Category will be the CategoryID of the direct parent
  6. Note that CategoryID is System Generated (auto-increment)

Please how do I achieve this using the same controller, and also with the same instance of upload.

 
 

Attachment: controller.zip

Answers (3)

0
Photo of John
NA 8 0 18y
Ok, how does this translate to the RTB control?

With properties such as Font, ForeColer, BackColor etc. It's simply a matter of selecting the text you want (best done via REGEX) then changing the back and forecolors.

So I think your question is how do I filter incoming ASCII data?  Use REGEX
How do I apply the formatting to the data? Use the RTB.properties and methods.
0
Photo of John
NA 8 0 18y

In the font world there are two types of fonts proportional and non-proportional.  Try using Courier New, it is a non-proportional font.

Your other issues, that of knowing the differences between RTF and regular text files is summed up with this statement: "They are both standards-based ways to present data to the end user."  

Here's the RTF standard.

http://www.microsoft.com/downloads/details.aspx?FamilyID=e5b8ebc2-6ad6-49f0-8c90-e4f763e3f04f&DisplayLang=en 

A Rich Text Box supports this standard.

TextBox is a more simple "standard" that has much less overhead.  I don't know the standard for Textbox support but feel it must be pretty simply  ASCII characters with very simple font control.