now im doing image processing project.. i got the problem with the coding.. i have 10 excel files.. lets say, each file, i need to select only column A then transfer to new excel.. same goes to column B, C, D and etc.. so, could you help me with c# coding and include the head of coding because im not good in c#.. thank you..
- Merged by Cindy Meister MVPMVP Monday, December 09, 2013 7:58 AM same issue
>> now im doing image processing project
>> because im not good in c#..
I am a bit confused with these statements. How are you doing the image processing project then? :)
Anyway, in case of the image processing project I would recommend using Open XML SDK without involving the Excel Object Model and running Excel in the background. Thus, it will increase the overall speed of your application.
Did you have a chance to look at the described above SDK and listed links?If you need to use the Excel Object Model, you may be interested in the Understanding the Excel Object Model from a .NET Developer's Perspective section in MSDN.
- Edited by Eugene Astafiev Sunday, December 08, 2013 2:57 PM
yes.. actually i do project of GPU.. so, the first thing i need to do is UWPI(ultrasonic wave propagation imaging).. i got the raw excel data (10 files) and i need to transpose the column and row.. then, each data transpose, i need to select column A and move to new excel.. same goes to column B, C, D until 500 column.. means, 10 raw excel will produce 500 new excel.. then, using 500 new excel, i need to process to image.. could you help me with the c# coding..??
As you have been already advised above...Open XML SDK (please see it only supports documents created in Office 2007 and above) is the right way to do. I would do the following if I were you:
1. Create a new C# Console application.
3. See the transpose example here. In the "new XLWorkbook()" constructor, you should give the complete path of the excel file you want to work on and in the "ws.Range()" method give the range of the rows you want to transpose and rest is pretty much the same. If you are not sure about the value to give as parameters in "ws.Range()", then an alternative is using "ws.RangeUsed()" with no parameters, provided the sheet only contains the relevant data that you require i.e. if the excel sheet contains multiple sets of data of tables in the same sheet spread across different cell ranges, then you'll have no other option then to ws.Range() method with target range addresses.
4. Once you are done transposing, retrieve the data from the excel file in datatable object as shown in the 2nd post here.
5. Repeat step 3 for all the excel files and keep on adding the result to the datatable object until the column count has reached 500 (or whatever you target is).
6. Once done, create a new excel file and insert the datatable object as shown here.
Thats it! I guess even if you dont have enough C# experience but just following the example I cited and you can easily get this done. If you have any questions do let me know.
P.S. I'll be grateful if you can mark my post as a reply if it solves your issue.
Akshaya K Sharma
>>i need to select column A and move to new excel.. same goes to column B, C, D until 500 column.. means, 10 raw excel will produce 500 new excel.. <<
If you want to move the colum to new WorkBook, you can refer to code below:
Sub CreateWorkBook() Dim sheet As Worksheet Dim aWorkbook As Workbook copyColumnCount = 5 Set sheet = Application.ActiveSheet For i = 1 To copyColumnCount sheet.Columns(i).Copy Set aWorkbook = Application.Workbooks.Add() aWorkbook.ActiveSheet.Paste aWorkbook.Save Next i End Sub
The code will generate 5 new Workbooks to default local file location, it usual is C:/Users/UserName/Documents. You can find the location at the File->Option->Save-> default local file location. You can change the copyColumnCount to the number you wanted to copy.
>>using 500 new excel, i need to process to image<<
What do you mean process to image?
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.
I'm confused about what you want to do. Before you get to the C# part, you don't you focus on the Excel part. Do you want to copy Column A from 10 Excel files in a folder? Is that the business requirements?
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.