|
I am aware of the RTB receiving the MouseWheel event. That is the event that I hooked. I DO want the entire panel to scroll. The RTB is a fixed size and does not fit the entire screen at once. I do not want the RTB to scroll. I am trying to somewhat mimic Microsoft Word, with multiple "pages" and you scroll through them. I have already removed the scroll bars from the RTB.
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|
|
Using COM interop with Excel|Ace 12 driver
Short background: Vendor delivers excel spreadsheet to be imported into our system. We had an agreed upon interface, and vendor did not meet the interface. I have been called in to shoehorn their data into the process.
Essentially, they put a piece of data in the incorrect column and it needs to be extracted from the existing column into a column of its own. They messed up on the datatype of another column, and TypeGuessRows is causing the Excel engine to infer that the column is numeric when in fact it is text.
If I can COM interop with the spreadsheet, extract the requisite data out of the current column, place it in its proper location within the sheet, then programmatically alter the datatype of the offending column from "General" directly to "Text", our existing process will be able to pick up fine. If not, the changes will be more invasive.
I cannot find any information at all on how to programmatically extract a column nor can I find any information on the interface that would allow me to change the datatype on an existing worksheet.
Does anyone know where I might find this information? Can anyone provide any examples of how either of these 2 tasks might be accomplished?
Would COM interop even be the way to go with this? Can you think of a better way?
"I need build Skynet. Plz send code"
modified 11-Nov-11 13:31pm.
|
|
|
|
|
Couldn't you write a function that uses OleDb to tranfer the column to the correct place and convert the data at the same time. Using OleDb you could treat the data as strings right from the start. This would be much easier than trying to do it with Interop. Then you could use your existing methods as they were meant to.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
How would *you* go about using OleDb to perform this task?
The only thing I can think of would be to use an OleDbDataReader to walk through the sheet and build another that matches the correct format in memory and when finished, save out to the original location.
"I need build Skynet. Plz send code"
|
|
|
|
|
I assumed you knew the name of the sheet and the index of the column the data is currently in and the index of the column you wish the data was in. Then it is merely a case of using a datareader to swop the columns with a data type change in the process.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
oh, I must have described the problem wrong then...
This is contrived, but I think it traps everything:
Sheet looks like this:
ColumnA | ColumnB | ColumnC | ColumnD
1)ColumnA contains data that needs to have a substring extracted and inserted as a new column between the existing ColumnA and ColumnB.
2)ColumnC is the wrong datatype.
maybe I'm just overthinking the problem.
"I need build Skynet. Plz send code"
|
|
|
|
|
never mind...I just needed to actually start writing the code to get the juices flowing
using (OleDbDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
string foo = reader[0].ToString();
string newcolumn = foo.Substring(foo.IndexOf(":") + 1);
object[] meta = new object[reader.FieldCount];
reader.GetValues(meta);
List<string> list = meta.ToList().ConvertAll(o => o.ToString());
}
}
"I need build Skynet. Plz send code"
|
|
|
|
|
Glad to help, even if it was just to get you thinking on a different track
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Ok...another mental block:
I can read the rows in the sheet, I can access the cells from the row via an OleDbDataReader
...but how do I hook directly into a row in the Excel spreadsheet to update it once I have my update record crafted?
using (OleDbCommand command = connection.CreateCommand())
{
int idx = 0;
command.CommandText = string.Format("select * from [{0}$]", "Report_12251104");
using (OleDbDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
string foo = reader[0].ToString();
string newcolumn = foo.Substring(foo.IndexOf(":") + 1);
object[] meta = new object[reader.FieldCount];
reader.GetValues(meta);
List<object> list = meta.ToList();
list.Insert(2,newcolumn);
}
OleDbCommand update = connection.CreateCommand();
update.CommandText = "update ??what exactly?? Can I use idx to id a row by number??";
update.ExecuteNonQuery();
idx++;
}
}
"I need build Skynet. Plz send code"
|
|
|
|
|
Hi
I have a web method (see below) which accepts an integer as a parameter. I want to be able to catch the error if a paramter is not provided. I thought using catch (ArgumentException) would do the job
Is there anything else i should be doing to be able to catch errors like this ?
thanks
Simon
[WebMethod]
public DataSet GetOrganisation(int organisationId)
{
DataSet ds = new DataSet();
try
{
.....
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
WriteToLog(organisationId.ToString(), "", "GetOrganisation", ex.Message);
}
catch (ArgumentException argerr)
{
WriteToLog(organisationId.ToString(), "", "GetOrganisation", argerr.Message);
}
return ds;
}
|
|
|
|
|
huh? you can't pass anything BUT an int to that method. Its not an optional parameter.
|
|
|
|
|
Notice that it's a web method. If somebody tries to call the web method via a web service, an exception will be thrown, but it can't be caught in that method. There may be another place to catch such errors on the server-side (before the client gets an exception), but I'm not sure.
Somebody in an online forum wrote: INTJs never really joke. They make a point. The joke is just a gift wrapper.
|
|
|
|
|
You mean if somebody builds their own raw XML and calls the method directly? If you use a generated proxy class and its "out of date", the proxy class will handle the exception. Not quite sure what you are trying to accomplish.
|
|
|
|
|
I'm not trying to accomplish anything. I was just clarifying what the OP seems to be trying to get at. Seems like they want to have control over what is returned in the case that a bad request is received (e.g., return a message that details which parameters were missing from the call).
Somebody in an online forum wrote: INTJs never really joke. They make a point. The joke is just a gift wrapper.
|
|
|
|
|
As long as you pass an integer, any integer, to this method no exception will be generated.
What you can do is check for a valid range then throw an exception if the variable passed to this method doesn't fall within that range. This can be done in several ways, hard coded, using Validation Application Block or Code Contracts. It's up to you.
No comment
|
|
|
|
|
Normally, in .NET I create wrapper classes for all of my web methods.
[WebMethod]
public FooBarResult FooBar(FooBarParameters parameters){
FooBarResult result = new FooBarResult();
try{
... do work here
}
catch(Exception e1){
... Perform logic to determine how much of the exception you can return and
... assign that to the result object in a special errors property
}
}
While not perfect in any manner it lets me consistently write web methods and always know how the results are coming back. I do a lot of cross platform WS work which is a real pain because both the Java tools and the .NET tool behave differently. This pattern gives a small semblance of sanity.
|
|
|
|
|
Question doesn't make any sense.
GetOrganisation() will not be invoke unless there is a value for organisationId.
So there is no way to test in that method whether a client called it with a value or not.
If you are asking about client code that calls that method then a much more likely error scenario is a communication fault. Although it is possible to call the server such that it is unable to resolve the method that is unlikely to be a valid scenario and it isn't a scenario that will exist for long. And even then it is a problem with the client code.
|
|
|
|
|
Does anyone knows how can i get properties of an mp3 file? such as artist, album etc.
what class shold i use?
|
|
|
|
|
The best thing is to use a 3rd party library. TagLib#[^] is an open source library from Novell, and id3DotNet[^] is another open source library on SourceForge.
Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
thanks
I added the TAGLIB library but i cant find the specific class i need.
|
|
|
|
|
This example assumes the MP3 file has at least one artist in the tag.
TagLib.File tagFile = TagLib.File.Create (mp3Filename);
System.Console.WriteLine ("Album = {0}", tagFile.Album);
System.Console.WriteLine ("Artist = {0}", tagFile.AlbumArtists[0]); /ravi
|
|
|
|
|
Search here on CP: there are many projects here, going back to 2002, that demonstrate how to get meta-information from .mp3 files.
"I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone." Bjarne Stroustrop circa 1990
|
|
|
|
|
I want to write 1 extension method,it's purpose is convert 1 IEnumerable<T> to 1 ObservableCollection<T>, but i've error :
Error 5 The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?)
Here is my code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Data;
namespace BookStore.Helper
{
public static class ExtensionMethods
{
public static ObservableCollection<T> ToObservableCollection(this IEnumerable<T> source)
{
ObservableCollection<T> target = new ObservableCollection<T>();
foreach (T item in source)
target.Add(item);
return target;
}
}
}
|
|
|
|
|
You need to add <T> to the method name. Try this:
public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> source)
{
ObservableCollection<T> target = new ObservableCollection<T>();
foreach (T item in source)
target.Add(item);
return target;
}
Hoep this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|