|
you send link to Visual Studio .NET 2003 ...?!
|
|
|
|
|
You can use COM interop with all versions of .Net.
This is an msdn link. You can change the version of .Net by choosing from a dropdown on the link next to Visual Studio 2003 mentioned on the website.
|
|
|
|
|
I can not understand way you send link for - Net 2003. Since I was able to make work com interop with excel 2003 but not with excel 2010. Why I need the link to .NET 2003?
|
|
|
|
|
having any idea?
ocr from japenese to english using c# with MODI
|
|
|
|
|
You can OCR the Japanese, but then you'll have to run that string through a translator, like http://www.microsofttranslator.com/[^]. Look at the "For Developers" link and start reading.
|
|
|
|
|
I'm getting the following error with VS2010 (still training), and, I can create a text file within this directory and as a matter of fact the executable is being created, so why is this error being displayed?
Warning GettingStarted Could not create output directory 'C:\Documents and Settings\Jon\My Documents\Visual Studio 2010\Projects\Training\CreateEventLog\GettingStarted\GettingStarted\bin\Debug\'. Access is denied.
1
Jon
|
|
|
|
|
It appears that your application which resides in the ...\bin\debug directory is attempting to create the folder in which it resides.
The key is in your error message. Cout not create output directory .
My suspicion is that you are using Directory.CreateDirectory instead of File.Create.
If you are using the sample from MSDN (http://msdn.microsoft.com/en-us/library/as2f1fez.aspx[^])
The safe way to do this is to always check if an object already exists before trying to create it.
if(!Directory.Exists "your directory path"))
{
Directory.CreateDirectory("your path");
}
FileStream fs;
if(!File.Exists("your file path"))
{
fs = File.Create("your file path");
}
else
{
fs = new FileStream("your file path", FileMode.Open);
}
if(File.Exists("your file path"))
{
File.Delete("your file path");
}
using(FileStream fs = File.Create("your file path"))
{
... Write stuff to the file here
}
using (FileStream fs = File.OpenRead(path))
{
... Read the contents of the file here
}
This MSDN FileStream[^] library article is a very good one to learn from.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
I am new to working with com objects and trying to figure out how to make this work. The code runs and it hits the if statement and even writes out the test message in the if statement. The problem is that when I open the excel file there is no change. It did somehow corrupt one and tell me that it is read only now and it will occasionally pop up the do you want to save this excel file message, but nothing ever shows. I have also tried Value and Value2 as I have seen in various pages, but I just can't find anything that does what I want it to do or any place that even gives good help on how to do it. This is the code I am using. A lot of it is just hardcoded test values so it really should be straight forward.
var excelDocument = new Excel.Application();
Excel.Workbook xlWorkbook = excelDocument.Workbooks.Open(@"c:/score/W5490C - Fresh.xlsx");
Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
Excel.Range xlRange = xlWorksheet.UsedRange;
int rowCount = xlRange.Rows.Count;
int colCount = xlRange.Columns.Count;
//Calculate and record the air losses.
int totalAircraftLostAA = 0;
int totalAircraftLostSA = 0;
ScoreCalculations.CalculateEnemyAirLosses(events, ref totalAircraftLostAA, ref totalAircraftLostSA);
int column = 3;
for (int row = 1; row <= rowCount; row++)
{
if (xlRange.Cells[row, 1].Value2.ToString() == "Aircraft Kills (A-A)")
{
Console.WriteLine(xlWorkbook.Sheets[1]);
Console.WriteLine("write attempted");
xlRange.Cells[row, column].Value2 = totalAircraftLostAA;
}
}
//Calculate and record ally airlosses
ScoreCalculations.CalculateAllyAirLosses(events);
//Calculate and record expended Ordnance
ScoreCalculations.CalculateExpendedOrdnance(events);
//Calculate and record ground targets hit
ScoreCalculations.CalculateNamedGroundTargets(events);
xlWorkbook.Save();
xlWorkbook.Close();
Thanks to anyone that can see what is probably the dumb mistake that I am making.
Jimmy
|
|
|
|
|
if (xlRange.Cells[row, 1].Value2.ToString() == "Aircraft Kills (A-A)")
You cannot compare strings like this, you need to use the String.Equals()[^] method.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
It seemed to work to get into the if statement at the right place based on what I was doing, but I switched the string.Equals just to be sure and it is still entering the if statement at the correct place, but that did not fix the issue. Thanks for letting me know that it was not proper to check the strings the way I was though. Any other ideas to fix why nothing is actually being written that I can see when I open the excel file?
|
|
|
|
|
JFRobertson wrote: why nothing is actually being written
Nothing obvious stands out in your code. If you cannot see the spreadsheet open when you run your code then add the following line after the Open() statement:
excelDocument.Visible = true;
The only other thing I would suggest is to step through with your debugger and see what values are being set in the worksheet.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I just copied your code and ran a test on this and it works fine, although I obviously could not use the ScoreCalculations methods, so I just plugged in some fixed values. As I said in my previous message, you probably need to use your debugger to find out what is going wrong.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Actually it was working. I thought I had verified that there were no hidden sheets, but I forgot to select them all before I clicked unhide. I am having an additional problem now. The code is working, but I have started to encapsulate it so I can make it better as well as start the process of finding which sheet rather than hardcoding, but it is crashing with a can not bind to a null object whether I call save or not. The big problem is that it is actually working even though it is giving the can't bind to a null object at runtime. Thank you for the help. I really hate that I spent so many years avoiding learning com interop, because now that I need it on a deadline it is killing me.
This is how I have modified the code. The calls are pretty much still the same just encapsulated but I am still hardcoding them.
Excel.Application excelDocument = ExcelOperations.GetApplication();
Excel.Workbook xlWorkbook = ExcelOperations.GetWorkbook(excelDocument);
Excel.Worksheet xlWorksheet = ExcelOperations.GetWorksheet("", xlWorkbook);
Excel.Range xlRange = ExcelOperations.GetRange(xlWorksheet);
try
{
var query = QueryTabDocument(columnsCount, filePath);
List<ScoreTabFile> events = query.ToList();
int rowCount = xlRange.Rows.Count;
int colCount = xlRange.Columns.Count;
int totalAircraftLostAA = 0;
int totalAircraftLostSA = 0;
ScoreCalculations.CalculateEnemyAirLosses(events, ref totalAircraftLostAA, ref totalAircraftLostSA);
int column = 3;
for (int row = 1; row <= rowCount; row++)
{
if (string.Equals(xlRange.Cells[row, 1].Value2.ToString(), "Aircraft Kills (A-A)"))
{
Console.WriteLine(xlRange.Cells[row, 1].Value2.ToString());
Console.WriteLine("write attempted");
xlRange.Cells[row, column].Value2 = totalAircraftLostAA;
}
}
ScoreCalculations.CalculateAllyAirLosses(events);
ScoreCalculations.CalculateExpendedOrdnance(events);
ScoreCalculations.CalculateNamedGroundTargets(events);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
GC.Collect();
GC.WaitForPendingFinalizers();
Marshal.FinalReleaseComObject(xlRange);
Marshal.FinalReleaseComObject(xlWorksheet);
xlWorkbook.Close();
Marshal.FinalReleaseComObject(xlWorkbook);
excelDocument.Quit();
Marshal.FinalReleaseComObject(excelDocument);
}
modified 12-Feb-12 16:15pm.
|
|
|
|
|
I'm afraid there's quite a bit in the above that's outside of my experience, so let's hope someone else comes by and offers some suggestions.
BTW it would help if you put your code between <pre> tags (use the code button above) to make it more readable; you can edit your messages to fix it.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Yes you can, the equality operators are overloaded to do value matching on strings in C#.
|
|
|
|
|
You learn something new every day.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Greetings.
I need to make a bar graphic divided by months. But the Axis' Type I'm using is DateAsOrdinal (instead of Text) and I need the bars to be inner the tics.
I read in zedgraph documentation that IsBetweenLabels only works with AxisType.Text.
GraphPane painel = masterPane[0];
PointPairList pointPairList = MyDataSource.getList();
BarItem barra = painel.AddBar(listastring, pointPairList, coresbarra[i]);
painel.XAxis.Type = AxisType.DateAsOrdinal;
painel.XAxis.MajorTic.IsBetweenLabels = true;
How can I resolve this? Thank you for your attention.
|
|
|
|
|
Hi all,
I'm fairly new at programming, having taken a few classes in college over the last semster. One thing I'm interested in doing is programming my own HTML editor or JavaScript editor.
I have absolutely no clue where to even begin. All my courses have taught the basics of programming by sending our output to a console window. I just purchased a C# book, and am waiting on it to arrive from Amazon.
My question (I know it took long enough to get to it) is if anyone can point me to any tutorials on how to create a standard text editor that can parse input and change the colors of the text like html editors and ide's do.
Thanks,
Jeramy
|
|
|
|
|
jeramyRR wrote: My question (I know it took long enough to get to it) is if anyone can point me to any tutorials on how to create a standard text editor that can parse input and change the colors of the text like html editors and ide's do.
May I suggest small steps? Like creating a text-editor[^] first, and then learn how to integrate a loading-routine with a parser? Or do you want to dive in directly[^]?
Bastard Programmer from Hell
|
|
|
|
|
No. No. Small steps first, most definitely. I want to learn the right way.
|
|
|
|
|
hey everyone plz help me.. i want to generate the html tree from xml file using XSLT ? is it possible ?
.. kindly reply.. regards..
modified 10-Feb-12 12:31pm.
|
|
|
|
|
Googling the following terms turned up 100,000+ hits. First synopsis of that list seemed relevant to me.
"html tree" xslt
|
|
|
|
|
hy.. no it didnt work for me..i need collapse and expand all functionality in the tree..but this code didnt work.anyways thanks
|
|
|
|
|
To be clear....
Xslt creates the html. The html, not the xslt, is responsible for the any behavior that you see. So the solution there is to first figure out what you need the html to do and then write the xslt to do it.
|
|
|
|
|
Hi
how can i convert the following txt file to xls file. perticular data in txt should be stored on pertular xls cell.
sample txt file:
txt1 txt2 txt3 txt4
txt5 txt6 txt7 txt8
txt4 txt3 txt2 txt1
This sample txt data (each "txt") should be stored in perticular xls cell.
can anyone give me a C# code which does this.
|
|
|
|