|
Hi,
Maybe this will help in better explaining what i wish to achieve.
I have excel document containing Cell Numbers and Names of customer. I want to be able to write custom text messages to all customers by concatenation typed text and data on excel such that i will be able to send same message to all the customers on the list for example. I will type "Hello" then insert the column name {Name} and proceed to add more text. This should ready "Hello Mike" where Mike is obtained from say cell A2 on my excel.
I am using C# and I have designed form as follows:
1. Option to select the excel with the cell numbers and name.
2. Text box, where am typing my text.
3. I have drop down list that populates the column headers from excel (eg Name, cell number).
4. I have a multi line text box where my messages will be displayed
I wish to compose my message as follows:
a. Enter text eg "Hello" and press add text to add text to the multi line text box
b. Select the column eg Name and click on Add Column to add column variable to the multi line text box
c. The text area should show 'Hello Mike' generated by Hello {Name}.
Am stuck at the point of merging/concatenation my typed text and data from excel to form one complete message.
Here is the screenshot of what i have done so far.
sshot.PNG - Google Drive[^]
|
|
|
|
|
So you can read the data from Excel ok, and - given the cell name - access the column.
But you are having problems replacing the text? That's trivial, compared to the excel bit...
The way I'd do it is to start with a regex: scan the input text for "{...}" data, and extract the content as a column name:
(?<ColName>{.*?}) Will do it.
The Matches collection will give you the name of column in Excel, surrounded by the curly brackets. Read that column from your Excel data, and use string.Replace to change all instances.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I've never seen anything like this, but I guess it's similar to a JQuery Json request in which you have a Url and the data is the querystring.
So for an example, https://secure.shippingapis.com/ShippingAPI.dll?API=RateV4&XML=<xml> is simply the request and you wait for the response on the XML page.
I have no clue how to transmit this and get the response XML. Just looking for suggestions.
I tried this but it just returns the request.
WebRequest request = WebRequest.Create(endpointUrl + txn);
WebResponse response = request.GetResponse();
Console.WriteLine(response.ResponseUri);
If it ain't broke don't fix it
|
|
|
|
|
I have this working for now, but it seems overkill. endpointUrl is the URL and txn is the XML, rxn is the return string to deserialize.
var httpWebRequest = (HttpWebRequest)WebRequest.Create(endpointUrl + txn);
httpWebRequest.ContentType = "application/xml";
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{<br />
streamWriter.Write("");
streamWriter.Flush();
streamWriter.Close();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
rxn = result.ToString();
}
If it ain't broke don't fix it
|
|
|
|
|
Would these encodings be the fault of the way I'm transmitting this from my previous post?
<MailService>Priority Mail Express 2-Day<sup>™</sup></MailService>
If it ain't broke don't fix it
|
|
|
|
|
the encoded stuff was just a trademark.
Works good enough now to finish the API
If it ain't broke don't fix it
|
|
|
|
|
hi thnx for helping me in past question
so i Reach here [ex image]
by using this code
private void Form1_Load(object sender, EventArgs e)
{
string img = @"D:\Capture1.PNG";
Bitmap bmp = new Bitmap(img);
pictureBox1.Image = Image.FromFile(img);
int w = bmp.Width;
int h = bmp.Height;
int f = 1;
Random rr = new Random();
for (int y=0;y < h ; y++)
{
for (int x=0 ; x < w ; x++)
{
int a = rr.Next(256);
int r = rr.Next(256);
int g = rr.Next(256);
int b = rr.Next(256);
bmp.SetPixel(x, y, Color.FromArgb(a, r, g, b));
}
}
pictureBox2.Image =bmp;
}
but the problem is the code chose random value to each pixel
how can i chose the value of the pixel and not make it random ?
|
|
|
|
|
Use Bitmap.GetPixel instead of Random.
I can't help thinking that if you invested as much work in thinking about the problem and actually looking at your code as you are in asking questions, you would get these tasks done a lot quicker and easier - this isn't complicated stuff you are doing here...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Dear All,
I have export one graph from placeholder by using save image file.
but i want export whole placeholder with graph in excel sheet like grid view export.
Please help me.
|
|
|
|
|
hi
I have a image
I want to change every pixel of this image to a different color
I know that every pixel in the picture is a number
I want to change the pixel color by changing its number by mathematical equation
for example
The original pixel number + number I chose
This process applies to every pixel in the picture
how i can do that
|
|
|
|
|
There's a bunch of articles on image processing around here, like this series[^].
|
|
|
|
|
|
WI54M wrote: how i can do that By programming a loop. What have you tried?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
You were given fairly detailed instructions on what you're going to have to do the last time you posted this question[^]. It's now up to you to actually write the code.
This space for rent
|
|
|
|
|
test
modified 27-Sep-17 6:46am.
|
|
|
|
|
I am sorry, but we won't do your homework for you. It's set to assess what you know, and to show you what areas you need to do more work on. It's not set to see what others know. If you are having problems with this, talk to your teacher.
This space for rent
|
|
|
|
|
What school? I'd like to point out to your teacher that your assignment sucks and should be shot.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
I have a C++ executable that consumes c# class library by importing the corresponding .tlb file. All works fine, except when I debug c# assembly by setting C++ executable as an external program, all the breakpoints in c# code says "The breakpoint will not currently be hit. No symbols have been loaded for this document"
FYI, I can debug C++ code, that's attached as an external program.
Below are few steps, I have already tried so far, but have no success.
1. Unregistered c# assembly and registered it back
2. Modified GUID and interface name, registered new assembly manually
Other details...
1. I am on Visual Studio 2010
2. For c# assembly, .NET target framework is 2.0, Register for COM interop is checked
3. I am using Win7 64 Bit version
Please let me know, in case any further details required.
Many Thanks
modified 27-Sep-17 0:34am.
|
|
|
|
|
Visual Studio needs access to the *.pdb file. See here[^] on help how to generate one.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I want to do a .Select for the rest of the fields: EventStatus, EventReason, and EventDateTime like I'm doing for the TrackingEvent and am not sure how to do that. Richard Deeming was helpful in get me started with this but need help with the rest.
TrackingEventHistory is the root for XML element I'm trying to output. The rest (EventStatus, EventReason, EventDateTime) are "children" within that root. There can be multiple TrackingEventHistory's so I'm trying to create a loop for the root and it's children. I'm not sure if .Select is the best way.
new XElement("TrackingEventHistory",
prc.History.Cast<Saia.Data.General.Shipment.HistoryItem>().Select(item => new XElement("TrackingEventDetail",
new XElement("EventStatus", EventCode.Delivered.ToXml()),
new XElement("EventReason", prc.History),
new XElement("EventDateTime", prc.History))
modified 26-Sep-17 17:31pm.
|
|
|
|
|
Rather than wasting your time getting stuck, posting a question and waiting for a reply, you should take some time to learn the basics of how XLINQ works. Fortunately for you, Sacha Barber wrote an excellent article on this topic. You can find it here[^].
This space for rent
|
|
|
|
|
Would something like this work
var query = (from c in doc.Root.Descendants("TrackingEvent") select c).ToList();
foreach (XElement element in query)
{
new XElement("EventStatus", EventCode.Delivered.ToXml()),
Response.Write(element.Value);
}
|
|
|
|
|
Why not try it and find out?
This space for rent
|
|
|
|
|
If you haven't downloaded it yet, you really should try out Linqpad[^]. Here's guidance[^] on how to query XLinq in it.
This space for rent
|
|
|
|