- My Forums
- Tiger Rant
- LSU Recruiting
- SEC Rant
- Saints Talk
- Pelicans Talk
- More Sports Board
- Fantasy Sports
- Golf Board
- Soccer Board
- O-T Lounge
- Tech Board
- Home/Garden Board
- Outdoor Board
- Health/Fitness Board
- Movie/TV Board
- Book Board
- Music Board
- Political Talk
- Money Talk
- Fark Board
- Gaming Board
- Travel Board
- Food/Drink Board
- Ticket Exchange
- TD Help Board
Customize My Forums- View All Forums
- Show Left Links
- Topic Sort Options
- Trending Topics
- Recent Topics
- Active Topics
Started By
Message
Iterating through Excel and adding to specific ArrayLists (C#) PAGING MAMOUTIGER
Posted on 4/23/15 at 4:21 pm
Posted on 4/23/15 at 4:21 pm
I have an excel sheet that shows jobs that are going through a rebuild process. Order is from left to right with the processing time beside it. I want to Iterate through to assign to certain ArrayLists in C#. These include Milling (M) CNC (C) Drilling (D) and Finishing (F). S# is the step in the process. I want to go rows first then columns (down the right). How would I do that? Is there a better way to store it? I want it to look like this...
Notice under Milling that J2S3 is 4 not 3. This is because under Drilling, J2S2 is 3 since J2S3 is after J2S2 in sequence to the job (can't run at same time).
Then I need to start adding the times in to get a schedule. I think I would like to store all of the Jobs end times (JobEndTime) into another ArrayList. This way it will continually update the previous steps end time.
To assign the scheduling time, I would reference to JobEndTime and take the max of Jobs last end time and previous stations end time then add the processing time of the new end time. How do I go about doing this?
Been stressing about this problem for weeks.
This post was edited on 4/23/15 at 4:25 pm
Posted on 4/23/15 at 4:43 pm to Hu_Flung_Pu
quote:
How do I go about doing this?
damn dude, you learn SQL
seriously you are putting excel through its paces here.
Posted on 4/23/15 at 5:34 pm to CAD703X
Thanks cad..... The 5.1 traitor
Posted on 4/23/15 at 7:18 pm to Hu_Flung_Pu
I'm assuming you know this, but you need to reference the Com interoperability library for excel. Define a range object that covers the table in the sheet you want to inspect. Then iterate the rows in the range. Within each row loop, iterate the columns of the current row.
Posted on 4/23/15 at 7:53 pm to Brisketeer
quote:
'm assuming you know this, but you need to reference the Com interoperability library for excel.
Yeah I knew that. I was gonna do a for loop and nest another one for rows.
I got those basics, I guess. I just don't know how to execute the loops and separate them into the array lists.
Posted on 4/23/15 at 8:01 pm to Hu_Flung_Pu
If you are using Office.Interop.Excel then check out this site LINK
Office Interop is really slow, uses lots of memory and requires Office to be installed on the server you deploy it to. An alternative would be OpenXML. You can read how to use it here LINK
If this is a small project and the computer running it will have Excel installed, then Interop should be fine.
Either way when you are looping through the columns and rows you can write to your arrays.
Office Interop is really slow, uses lots of memory and requires Office to be installed on the server you deploy it to. An alternative would be OpenXML. You can read how to use it here LINK
If this is a small project and the computer running it will have Excel installed, then Interop should be fine.
Either way when you are looping through the columns and rows you can write to your arrays.
This post was edited on 4/23/15 at 8:06 pm
Posted on 4/23/15 at 8:15 pm to MamouTiger65
ClosedXML is a simpler wrapper around OpenXML. Try that as well.
LINK
LINK
Posted on 4/23/15 at 8:36 pm to MamouTiger65
quote:
Either way when you are looping through the columns and rows you can write to your arrays.
How do I assign to different arrays using another column to determine which array to in?
Posted on 4/23/15 at 9:39 pm to Hu_Flung_Pu
I just played around with it and the easiest thing for me was to make a 2d array using Jobs and Hours.
Each hour can use up to 4 stations. None of the stations can be the same, and each job can only have one station per hour. If a station has already been used in a given hour then increment it to the next hour.
May need some tweaking but hope that helps.
Each hour can use up to 4 stations. None of the stations can be the same, and each job can only have one station per hour. If a station has already been used in a given hour then increment it to the next hour.
May need some tweaking but hope that helps.
This post was edited on 4/23/15 at 9:41 pm
Posted on 4/23/15 at 9:48 pm to MamouTiger65
Would it work if it was two separate times? I only did 1hour for all to be easier during testing
Posted on 4/23/15 at 10:07 pm to Hu_Flung_Pu
I think it would. For each job, each hour you would track the station and the time it takes to complete.
If a station takes 2 hours then mark the current hour and the next hour with that station for the given job.
If that station is set to be used in the same step of another job, then just increment down by the time of the first and start marking at that point.
Without playing with it much more I'm going to stick with the job X hours array. It will just be key to have checks to make sure a station is only used once per row and tracking how far to increment for each job.
If a station takes 2 hours then mark the current hour and the next hour with that station for the given job.
If that station is set to be used in the same step of another job, then just increment down by the time of the first and start marking at that point.
Without playing with it much more I'm going to stick with the job X hours array. It will just be key to have checks to make sure a station is only used once per row and tracking how far to increment for each job.
Posted on 4/24/15 at 9:27 am to MamouTiger65
Brilliant man. I worked through one manually to see if it correlates with the other schedule and it does! I think that would be easier. Is there a preferred method of checking within an ArrayList for certain substrings?
Here is what I had as the ArrayList.
Like I wanna take
J3M3
//Search for previous J3 (J3C2) = 3
//Search for previous or equal M (J2M3) = 4
Take max of both and add processing time to max
Here is what I had as the ArrayList.
Like I wanna take
J3M3
//Search for previous J3 (J3C2) = 3
//Search for previous or equal M (J2M3) = 4
Take max of both and add processing time to max
Posted on 4/25/15 at 1:06 pm to CAD703X
No shite, he's re-engineering the wheel for real...
Posted on 4/25/15 at 3:07 pm to Hu_Flung_Pu
Why arraylists? Why not generic lists?
Posted on 4/25/15 at 3:25 pm to yankeeundercover
quote:
No shite, he's re-engineering the wheel for real...
It's so I can run all of it from a windows form. Excel is just the basis to hold the info.
Popular
Back to top
Follow TigerDroppings for LSU Football News