15,904,339 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Silver Lightning (Top 89 by date)
Silver Lightning
11-Jan-18 19:22pm
View
Hi Sir, the page shouldn't be stopped because its getting an update from the database. what I'm trying to impose right now is to implement a jquery.countdown.js and put a timer inside. that timer would still continue even the page is refreshing. when the timer reached 30 minutes then the web application will re-directing to login page (session time out). Then, if the event is coming from the mouse or keyboard then that's the only time that my implemented timer will be reset. Do you think it's the right way to do to execute the session timeout? Any sample code on how could I implement the timer that will not reset even the page is refreshing? Thank you very much for your advised and helping my case here sir. :)
Silver Lightning
11-Jan-18 0:34am
View
Hi Sir,
I would like to implement a timer that would not reset even the page is refreshing, the session timeout was set to 30 minutes. The only interruption that could reset the session time out is when the event is coming from the keyboard press and mouse click. I found the jquery.countdown.js but I don't know on how to implement the right code that the timer should not reset even the page is always refreshing. Thank you very much for your help in advance Sir.
Silver Lightning
10-Jan-18 21:47pm
View
Hi Sir,
Thank you for your help. Yes I'm thinking of an internal timer, but how could I ignore the system's refreshing in every two seconds. the timer will always be reset. How could I make the time to continue and will not reset for 30 minutes even the page is always reloading or refreshing?
Silver Lightning
13-Dec-17 21:07pm
View
Deleted
Hi Sir Richard, yes I know. OpenXML is the recommended way to implement this task. But however, this is an existing one that I need to fix. Can you suggest or give sample code on how could I check or find the "All Section" column in all sheets using this Microsoft.Office.Interop.Excel. Thank you very much for the respond.
Silver Lightning
23-Jun-17 0:05am
View
Hi Richard, sorry it's my fault.
Silver Lightning
13-Jun-17 19:38pm
View
do anyone knows how to consume this api with multiple parameter? thank you in advance
Silver Lightning
13-Jun-17 18:57pm
View
sorry richard. hope someone assist me on this. thank you
Silver Lightning
18-Jan-17 5:30am
View
Thanks Singh
It's always resulting to invalid URL even the input URL is valid:
sample valid URL:
http://www.bigwinnerme.com
Could you elaborate more?
Silver Lightning
18-Jan-17 5:21am
View
Thanks sir. how about the URL link like this?
https://www.com
How could I make this invalid when the user input a URL like on the above case?
Silver Lightning
18-Jan-17 4:32am
View
Thank you sir. but
'http://ww.try.net' is Invalid (requirement)
because ww. should be www.
how can I adjust the regex to validate that the above URL is INVALID?
Silver Lightning
18-Jan-17 4:02am
View
thanks sir, but can you give me an updated regex code to set the http://ww.try.net' to become invalid?
Silver Lightning
18-Jan-17 3:28am
View
Deleted
'http://ww.try.net' should be Invalid
because ww. should be www.
how can I adjust the regex to validate that the above URL is INVALID?
Silver Lightning
23-Nov-16 23:47pm
View
Could someone guide me on how could I use Callback in unit test MOQ Recursion in C#? Thank you in advance
Silver Lightning
17-Nov-16 18:24pm
View
Can anyone help me on how could I implement callback in MOQ in recursive method. (Calling the same method inside this method)? Thank you in advance.
Silver Lightning
15-Nov-16 18:20pm
View
You mean, I need to write new method inside the ChangeFilterAttribute? can you give me sample pseudocode or something? Thank you very much
Silver Lightning
24-Jul-14 5:14am
View
It works, please accept my highest gratitude to you...
Silver Lightning
31-Jan-13 20:35pm
View
Thank you Sir Dave. Apology for my late reply.
Silver Lightning
31-Jan-13 0:04am
View
Thank you agent sales. but that is not correct.
Silver Lightning
30-Jan-13 23:44pm
View
Ok Sir Dave, can you give me a sample code on how could I create my own itemarray based on ResultDataTable and Create it to a new one? Thank you Sir =)
Silver Lightning
30-Jan-13 21:25pm
View
Ok Sir Dave, thank you, I want is to add column value in ResultDataTable which has already a column of ID, NAME and DESCRIPTION which has already a data inside them. I want to add new column name ACTION, where I can tag or indicate a value of EDIT, DELETE or UPDATE.
How could I add a column to ResultDataTAble on this sample code below:
ResultDataTable.LoadDataRow(parentrow.ItemArray, True)
Note: parentrow has a value of ID, NAME and DESCRIPTION.
I want to add new column named ACTION to ResultDataTable.
Thank you in advance sir.
Silver Lightning
30-Jan-13 20:49pm
View
Thank you sir,but that is not correct. I already adding the data to ResultDataTabe, I only wanted is to add another column value in ResultDatableTable which is not existing to firstdatatable and seconddatatable. I mean how can I play around ItemArray to add new column in ResultDataTable?
Silver Lightning
18-Jan-13 2:27am
View
Thank you Sir SA
Silver Lightning
18-Jan-13 1:48am
View
Hi Sir SA,
Thanks for your time. I think you don't understand my queries. The code above is working, but I need to eliminate the swf file (adobe flash plug-in), but when I dropped it, the program is not working anymore. Do you have any idea on how could I update the code above? Thank you in advance. God bless =)
Silver Lightning
17-Jan-13 23:35pm
View
Thanks Sir SA,
Based on my code above, do you have any idea on how could I make it without using the .swf and swfojbect.js? I need to implement uploading file using jquery only in asp.net. I hope someone could help me or direct me to right path. Thank you
Silver Lightning
17-Jan-13 20:34pm
View
Hi Sir,
Here is my code which is not allowed to use in our office, especially using the uploadify.swf and swfobject.js
MY CLIENT SIDE CODE:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link href="_scripts/uploadify.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="_scripts/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="_scripts/swfobject.js"></script>
<script type="text/javascript" src="_scripts/jquery.uploadify.v2.1.4.min.js"></script>
<title>Untitled Page</title>
<script type="text/javascript">
$(document).ready(function() {
$('#fuFiles').uploadify({
'uploader': '_scripts/uploadify.swf',
'script': 'FileUploads.aspx',
'cancelImg': '_scripts/cancel.png',
'auto': 'true',
'multi': 'true',
'buttonText': 'Browse...',
'queueSizeLimit': 3,
'simUploadLimit':2
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="fuFiles"></div>
</form>
</body>
</html>
MY CODE BEHIND:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class FileUploads : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpPostedFile uploads = Request.Files["FileData"];
string file = System.IO.Path.GetFileName(uploads.FileName);
try
{
uploads.SaveAs("D:\\UploadedUserFiles\\" + file);
}
catch
{
}
}
}
---
Is there another way that I could only use is the jquery.uploadify only? not the uploadify.swf and swfobject.js?
I hope you could help me on this Sir. Thank you
Silver Lightning
17-Jan-13 4:32am
View
Thanks sir but still not working out. I need to do it in Jquery. is there any other option using jquery?.
Silver Lightning
8-Oct-12 20:00pm
View
Deleted
I hope somebody could see this. still no answer.
Silver Lightning
3-Oct-12 19:05pm
View
Sir, can you give me any vb.net sample code?
Silver Lightning
9-Jul-12 2:40am
View
is this issue resolved?
Silver Lightning
9-Jul-12 2:28am
View
thank you sir. it helps. God bless. :)
Silver Lightning
24-May-11 23:19pm
View
Hi Sir Wonde,
I made it. I only removed the outer foreach loop in mainarea it it's done.
Thanks for your help and concern sir.
God speed.. 'till next time and thank you codeproject.com
=)
Silver Lightning
24-May-11 23:08pm
View
thanks sir Wonde,
I already did that but still the same output resulted.
Here's my updated code inside the foreach loop
foreach (string clustName in dictClustName.Keys)
{
if (dictClustName[clustName].ToString() == cs.CL1)
//if (mainArea.Trim() == cs.CL1)
{
iCtr++;
and also filtered if clustFlag is false
else if (!clustFlag)
{
string strMainArea = dictClustName[clustName].ToString();
//if (strMainArea == cs.CL1)
if (dictClustName.ContainsValue(cs.CL1))
{
string cValueMainArea = dictClustName[clustName];
if (cValueMainArea.Trim() == cs.CL1)
{
//Dummy blank
blankOutput = " " + "," + clustName + "," + "0" + "," + "0" + "," +
"0" + "," + "0" + "," +
"0%" + "," + "0%" + "," + TAG.G3 + ",";
tw.Write(clustName + blankOutput);
}
}
I don't where could I filter more or where I could control foreach loop. Please help me sir. Thank you in advance.
Silver Lightning
24-May-11 21:49pm
View
Thanks sir Wonde,
I already updated my code above, can you help me sir on my dictionary statement above, which the mainArea field is not changing even the cluster field key is changed and it's value where it was the mainArea is no more cs.CL1. I already indicated some comment on my updated code above. Thank you in advance sir. Please help me
Silver Lightning
19-May-11 5:26am
View
the data table is the answer.... thank you so much sir. =)
Silver Lightning
19-May-11 5:01am
View
Thanks for your help too sir nit_singh.
I really appreciated that. It helps me too.
Have a nice day and God bless... :)
Silver Lightning
19-May-11 4:59am
View
thanks for the help sir... I greatly appreciated that.
It helps me a lot.
God bless and more power...
Silver Lightning
19-May-11 4:55am
View
what is 4xn matrix sir?
Silver Lightning
19-May-11 4:31am
View
great solution sir senguptaamlan,
just one more sir, how could I make the output of the combineList in 1 row per record (1st record from list1, list2, list3, list4), because it resulting to 1 line per record... is there anyway that it could be CONCATED?
EX:
the first record of combineList should display like this:
(1ST RECORD DISPLAY): DOG, GLASS, PEN, UMBRELLA
(2ND RECORD DISPLAY): CAT, HAMMER, NOTEBOOK, BAG
AND SO ON...
thanks for your help sir...
Silver Lightning
19-May-11 3:45am
View
hi sir nit_singh,
Thank you very much for your help sir nit_singh. it works, just one more concern sir,
how could I make them in 1 row (per record), I mean, the lstAll collection displays it per group.
that's my primary concern.
example: (based on above sample data)
the output should be: (from lstAll)
1, 3, 5, 7,
2, 4, 6, 8,
9,
please help me sir.
Silver Lightning
19-May-11 1:49am
View
Thanks for the help Sir senguptaamlan,
what would I update if my data has different no. of elements?
example is the FourthList has 5 records?
please help me
Thank you sir and God speed...
Silver Lightning
19-May-11 0:09am
View
hi sir Stops,
I improved the program we've done... I have a query
on how to merge all my 4 list collections in 1 list where
each record of my 4 list collection must be displayed.
here's the link sir sTops
http://www.codeproject.com/Questions/198468/How-to-merge-4-list-collections-in-1-list-collecti.aspx
Silver Lightning
18-May-11 23:59pm
View
Deleted
here's my code sir, please help me:
List<string> lister1 = new List<string>();
List<string> lister2 = new List<string>();
List<string> lister3 = new List<string>();
List<string> lister4 = new List<string>();
int ToTal = 0;
foreach (string Tag in main_area.Keys)
{
foreach (string MainArea in main_area[Tag].Keys)
{
foreach (string Cluster in main_area[Tag][MainArea].Keys)
{
Console.WriteLine("{0} {1} {2} count: {3}", Tag, Cluster, MainArea, main_area[Tag][MainArea][Cluster]);
ToTal += main_area[Tag][MainArea][Cluster];
// reformatting
if (Tag.Trim() == "3G")
{
string out3G = Tag + " " + MainArea + " " + Cluster + " " + main_area[Tag][MainArea][Cluster];
lister1.Add(out3G);
}
if (Tag.Trim() == "GBB")
{
string outGBB = Tag + " " + MainArea + " " + Cluster + " " + main_area[Tag][MainArea][Cluster];
lister2.Add(outGBB);
}
if (Tag.Trim() == "DL")
{
string outDL = Tag + " " + MainArea + " " + Cluster + " " + main_area[Tag][MainArea][Cluster];
lister3.Add(outDL);
}
if (Tag.Trim() == "WX")
{
string outWX = Tag + " " + MainArea + " " + Cluster + " " + main_area[Tag][MainArea][Cluster];
lister4.Add(outWX);
}
}
}
}
// Display output
List<string> allList = new List<string>();
allList.AddRange(lister1);
allList.AddRange(lister2);
allList.AddRange(lister3);
allList.AddRange(lister4);
Console.WriteLine();
foreach (string rec in allList)
{
Console.Write(rec);
}
}
Silver Lightning
17-May-11 5:23am
View
Hi Sir Stops,
It works... thank you for helping me sir...
God bless and more power to you....
Please accept this GIFT AFFIRMATION:
"I see you success,healthy, wealthy and happy in your life..." =)
'till next time...
Silver Lightning
17-May-11 5:08am
View
thanks you sir Stops for helping me,
your updated code producing an error:
Error 1 Cannot implicitly convert type 'int' to 'System.Collections.Generic.Dictionary<string,int>
on this part of the code:
// adding cluster name key
if(!Region[main_area].ContainsKey(cluster))
{
Region[main_area][cluster] = 0;
}
thanks sir..please help me
Silver Lightning
17-May-11 4:49am
View
thank you for immediate response sir sTops,
the code you've given is only sum up if
the same value of EXC_TO_COM_DAYS.
eg: if I change the value of EXC_TO_COM_DAYS of "BATAAN" from 1 to 2 in the first record, the 7th record which has the same of 1st record value(BATAAN also) will not sum up. Because it has a value of 1 which is now different from 1st record which I changed to 2. The output should result to 1 record if it has the same MAIN_AREA and CLUSTER. Please help me sir. I know it's too much. But I really needed it badly.
Thank you and God bless...
Silver Lightning
17-May-11 4:30am
View
Hi Sir Stops,
thanks responding, I tried that code but the output is not accurate,
the code:
// adding cluster name key
if (!Region[main_area].ContainsKey(cluster))
{
Region[main_area][cluster] = new Dictionary<string, int="">();
}
Region[main_area][cluster][excDays] = 0;
will reset the record in summing up the value from 1st record which is the same in the 7th record.
they have the same MAIN_AREA and CLUSTER field value, I need to sum-up the total value of all EXC_TO_COM_DAYS, as you can see if you test my old code the (cluster field)BATAAN name with (main area)CL1 has 2 value, but now it becomes 1 which is wrong.
please help me on this sir. thank you in advance
Silver Lightning
17-May-11 3:41am
View
hi sir Thomas,
Even if I use the Dictionary, I'm getting the same error "KEY WAS NOT PRESENT IN THE DICTIONARY". Can you see what went wrong to my code sir?
thank you in advance sir. please help me
Silver Lightning
16-May-11 2:45am
View
a quite bit on parenthesis
Silver Lightning
16-May-11 1:23am
View
ok sir, thanks, I did. :)
God speed...
Silver Lightning
13-May-11 5:16am
View
thank you very much sir... =)
Silver Lightning
13-May-11 3:41am
View
that's my problem sir, I'm thinking of ArrayList, but it only holds the name of animal values, how about the number values to parallel with them and handle them both.
Silver Lightning
13-May-11 2:36am
View
Hi Sir d@nish,
Here's my code...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.IO;
namespace Clustering_Test
{
class Program
{
static void Main(string[] args)
{
// Variable declaration (animal names)
string strAnimal = String.Empty;
string catName;
int garfieldBlackCtr = 0, garfieldWhiteCtr = 0, garfieldBrownCtr = 0;
int BellaBlackCtr = 0, BellaWhiteCtr = 0, BellaBrownCtr = 0;
int KittaBlackCtr = 0, KittaWhiteCtr = 0, KittaBrownCtr = 0;
int LassieBlackCtr = 0, LassieWhiteCtr = 0, LassieBrownCtr = 0;
int SkitterBlackCtr = 0, SkitterWhiteCtr = 0, SkitterBrownCtr = 0;
int MoussyBlackCtr = 0, MoussyWhiteCtr = 0, MoussyBrownCtr = 0;
int RattyBlackCtr = 0, RattyWhiteCtr = 0, RattyBrownCtr = 0;
string dogName, dogColorCtr;
string mouseName, mouseColorCtr;
string strGarfield, strBella, strKitta;
string strLassie, strSkitter;
string strMoussy, strRatty;
// Reading input text file
string dirFile = @"C:\FileDir\Sample_Text.txt";
string recLine;
int recCounter = 0;
StreamReader srTable = new StreamReader(dirFile);
while ((recLine = srTable.ReadLine()) != null)
{
recCounter++;
strAnimal = recLine.Substring(0, 5);
if (strAnimal == "CAT")
{
// Get the name of the cat
catName = recLine.Substring(12, 9);
if (catName.Trim() == Cat.GARFIELD)
{
// Get the color count
string valCatColor = recLine.Substring(23, 3);
garfieldBlackCtr = Convert.ToInt32(valCatColor.Trim());
Process.intGarfieldBlack += garfieldBlackCtr;
string valCatColor2 = recLine.Substring(35, 3);
garfieldWhiteCtr = Convert.ToInt32(valCatColor.Trim());
Process.intGarfieldWhite += garfieldWhiteCtr;
string valCatColor3 = recLine.Substring(47, 3);
garfieldBrownCtr = Convert.ToInt32(valCatColor.Trim());
Process.intGarfieldBrown += garfieldBrownCtr;
// and so on...with BELLA and KITTA
// but the risk on this code, if new cat name occurred,
// I don't know how to handle new names and what variable counters
// could handle them... please help me on this sir. thanks
}
}
else if (strAnimal == "DOG")
{
// Get the name of the dog
dogName = recLine.Substring(12, 9);
if (dogName.Trim() == Dog.LASSIE)
{
// Get the color count
string valDogColor = recLine.Substring(23, 3);
LassieBlackCtr = Convert.ToInt32(valDogColor.Trim());
Process.intLassieBlack += LassieBlackCtr;
string valDogColor2 = recLine.Substring(35, 3);
LassieWhiteCtr = Convert.ToInt32(valDogColor.Trim());
Process.intLassieWhite += LassieWhiteCtr;
string valDogColor3 = recLine.Substring(47, 3);
LassieBrownCtr = Convert.ToInt32(valDogColor.Trim());
Process.intLassieBrown += LassieBrownCtr;
// and so on... with SKITTER
// but the risk on this code, if new cat name occurred,
// I don't know how to handle new names and what variable cou
Silver Lightning
13-May-11 0:43am
View
Deleted
thanks sir, I'll post my code
Silver Lightning
12-May-11 21:15pm
View
pls help me sir
Silver Lightning
12-May-11 21:15pm
View
pls help me sir
Silver Lightning
12-May-11 20:58pm
View
it's console application, I'm reading a text file using the StreamReader and TextWriter like this one:
StreamReader file = new System.IO.StreamReader(CatchedFile, System.Text.Encoding.Default);
TextWriter tw = new StreamWriter(outFile, true, System.Text.Encoding.Default);
Silver Lightning
12-May-11 20:25pm
View
Thank you sir, I tried to make a code but the name of the animal is hard coded which is wrong, because the user might be added new names and number value on it which is my primary problem (handling the animal names and number values in a flexible way)
I hope you could help me even a snip code
Thank you in advance.
Silver Lightning
28-Mar-11 22:02pm
View
I got the answer using aspnet_regiis -i
thank you for your help sir dave. :)
Silver Lightning
28-Mar-11 20:52pm
View
I already did that sir, but still the same error, resulted to failed to access IIS metabase. here's my reference http://support.microsoft.com/?kbid=267904
but still the same error occurred. Any help about this sir? thanks in advance
Silver Lightning
23-Mar-11 3:43am
View
thanks sir, I did it through updating the user authentication in folder. Have a nice day & God bless...
Silver Lightning
22-Mar-11 22:33pm
View
thanks sir, but still not working, the error is on how could I access a particular directory that my web application is using. can you give me a simple solution sir? thanks
Silver Lightning
22-Mar-11 21:45pm
View
I already did sir, but I can't find the asp.net account. I'm using windows7. what would I do sir? thanks
Silver Lightning
9-Mar-11 3:41am
View
Thanks sir Prerak. :)
Silver Lightning
9-Mar-11 0:57am
View
thanks sir, but I used only the windows authentication, I have no sql server authentication.What will I do sir?
Silver Lightning
9-Mar-11 0:06am
View
what do you mean sir? can you give an example? thanks
Silver Lightning
8-Mar-11 21:56pm
View
Please help me on this sir. Your help is really much appreciated.
Silver Lightning
7-Mar-11 4:43am
View
I already did that sir, but still not displaying. What do you think should I revise? Thanks
Silver Lightning
7-Mar-11 4:37am
View
Hi Sir Eduard,
Still not displaying while application is running, but in design view it shows.
Silver Lightning
7-Mar-11 4:11am
View
yes sir it is correct, in fact, it was displaying in design view, but when I'm running the application, it is not displaying. please help me sir. thanks
Silver Lightning
7-Mar-11 3:51am
View
Still no answer, please help me on this sir. Thanks
Silver Lightning
17-Feb-11 0:03am
View
Hi Sir Henry,
Do you have any idea on how could I update this code? here's link. No one wants to answer my question (except the developer ramalinga). Please help me. Thanks
http://www.codeproject.com/Answers/158126/Need-a-sample-code-on-how-to-use-the-excel-autofit.aspx#answer1
Silver Lightning
16-Feb-11 2:41am
View
could anyone help? thanks
Silver Lightning
16-Feb-11 0:10am
View
Thanks sir Ramalinga, but where in the program could I put that code? Here's the complete program code below, just guide me a little sir. thank you and God bless
===================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Excel = Microsoft.Office.Interop.Excel;
namespace IROCtrans
{
public partial class frmIroc : Form
{
public frmIroc()
{
InitializeComponent();
}
//-----------------
// Excel object references.
private Excel.Application m_objExcel = null;
private Excel.Workbooks m_objBooks = null;
private Excel._Workbook m_objBook = null;
private Excel.Sheets m_objSheets = null;
private Excel._Worksheet m_objSheet = null;
private Excel.Range m_objRange = null;
private Excel.Font m_objFont = null;
private Excel.QueryTables m_objQryTables = null;
private Excel._QueryTable m_objQryTable = null;
//- ----------------
// Frequenty-used variable for optional arguments.
private object m_objOpt = System.Reflection.Missing.Value;
// Paths used by the sample code for accessing and storing data.
private object m_strSampleFolder = "D:\\Sonix\\TryCode\\";
private void frmIroc_Load(object sender, EventArgs e)
{
cmbSelect.DropDownStyle = ComboBoxStyle.DropDownList;
cmbSelect.Items.AddRange(new object[]{
"Convert Text File to Excel File",
"Exit"});
cmbSelect.SelectedIndex = 0;
cmdConvert.Text = "&Access";
}
private void cmdConvert_Click(object sender, EventArgs e)
{
switch (cmbSelect.SelectedIndex)
{
case 0:
Convert_TextFile();
break;
case 1:
Exit_Application();
break;
}
//Clean-up
m_objFont = null;
m_objRange = null;
m_objSheet = null;
m_objSheets = null;
m_objBooks = null;
m_objBook = null;
m_objExcel = null;
GC.Collect();
}
private void Exit_Application()
{
cmdConvert.Text = "";
cmdConvert.Text = "Exiting...";
System.Threading.Thread.Sleep(3000);
this.Close();
}
private void Convert_TextFile()
{
// Open the text file in Excel.
m_objExcel = new Excel.Application();
m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;
m_objBooks.OpenText(m_strSampleFolder + "test-data.csv",
Excel.XlPlatform.xlWindows, 1,
Excel.XlTextParsingType.xlDelimited,
Excel.XlTextQualifier.xlTextQualifierDoubleQuote,
false, true, false, false, false, false, m_objOpt, m_objOpt,
m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);
m_objBook = m_objExcel.ActiveWorkbook;
// Save the text file in the typical workbook format and quit Excel.
m_objBook.SaveAs(m_strSampleFolder + "test-data.xls",
Excel.XlFileFormat.xlWorkbookNormal,
m_objOpt, m_objOpt, m_objOpt, m_objOpt,
Excel.XlSaveAsAccessMode.xlNoChange,
m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);
m_objBook.Close(false, m_objOpt, m_objOpt);
m_objExcel.Quit();
Excel.Range xlEntireColumn = null;
Excel.Range xlRange = null;
}
}
}
Silver Lightning
16-Feb-11 0:08am
View
Deleted
Thanks sir Ramalinga, but where in the program could I put that code? Here's the complete program code below, just guide me a little sir. thank you and God bless
==========================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Excel = Microsoft.Office.Interop.Excel;
namespace IROCtrans
{
public partial class frmIroc : Form
{
public frmIroc()
{
InitializeComponent();
}
//-----------------
// Excel object references.
private Excel.Application m_objExcel = null;
private Excel.Workbooks m_objBooks = null;
private Excel._Workbook m_objBook = null;
private Excel.Sheets m_objSheets = null;
private Excel._Worksheet m_objSheet = null;
private Excel.Range m_objRange = null;
private Excel.Font m_objFont = null;
private Excel.QueryTables m_objQryTables = null;
private Excel._QueryTable m_objQryTable = null;
//- ----------------
// Frequenty-used variable for optional arguments.
private object m_objOpt = System.Reflection.Missing.Value;
// Paths used by the sample code for accessing and storing data.
private object m_strSampleFolder = "D:\\Sonix\\TryCode\\";
private void frmIroc_Load(object sender, EventArgs e)
{
cmbSelect.DropDownStyle = ComboBoxStyle.DropDownList;
cmbSelect.Items.AddRange(new object[]{
"Convert Text File to Excel File",
"Exit"});
cmbSelect.SelectedIndex = 0;
cmdConvert.Text = "&Access";
}
private void cmdConvert_Click(object sender, EventArgs e)
{
switch (cmbSelect.SelectedIndex)
{
case 0:
Convert_TextFile();
break;
case 1:
Exit_Application();
break;
}
//Clean-up
m_objFont = null;
m_objRange = null;
m_objSheet = null;
m_objSheets = null;
m_objBooks = null;
m_objBook = null;
m_objExcel = null;
GC.Collect();
}
private void Exit_Application()
{
cmdConvert.Text = "";
cmdConvert.Text = "Exiting...";
System.Threading.Thread.Sleep(3000);
this.Close();
}
private void Convert_TextFile()
{
// Open the text file in Excel.
m_objExcel = new Excel.Application();
m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;
m_objBooks.OpenText(m_strSampleFolder + "test-data.csv",
Excel.XlPlatform.xlWindows, 1,
Excel.XlTextParsingType.xlDelimited,
Excel.XlTextQualifier.xlTextQualifierDoubleQuote,
false, true, false, false, false, false, m_objOpt, m_objOpt,
m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);
m_objBook = m_objExcel.ActiveWorkbook;
// Save the text file in the typical workbook format and quit Excel.
m_objBook.SaveAs(m_strSampleFolder + "test-data.xls",
Excel.XlFileFormat.xlWorkbookNormal,
m_objOpt, m_objOpt, m_objOpt, m_objOpt,
Excel.XlSaveAsAccessMode.xlNoChange,
m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);
m_objBook.Close(false, m_objOpt, m_objOpt);
m_objExcel.Quit();
Excel.Range xlEntireColumn = null;
Excel.Range xlRange = null;
while (reader.Read())
{
for (int i = 0; i < numcols; i++)
{
xlsheet.ActiveSheet.Cells[row, i + 1] = reader.GetValue(i).
Silver Lightning
15-Feb-11 1:06am
View
thanks sir, but I need to transfer all data in text file to excel file (include headers and by columns). Any idea or code that I on how could I expand your given code sir? Your help really much appreciated. Thank you sir corsairsoft.
Silver Lightning
14-Feb-11 20:42pm
View
Ooopps sorry sir, yes your link is correct, do you think it is possible that I could convert all the parsed string from array to excel file? do you have any sample code? thanks sir
Silver Lightning
14-Feb-11 20:36pm
View
Deleted
Thanks sir, but I already read that link, it has many token errors which I could not understand. Can you give me a little sample code sir? thanks and God bless...
Silver Lightning
13-Feb-11 20:32pm
View
Hi Sir Henry, can ask sample code on how to get the fixed space delimited text file (as a sample above text file) and and store it on the array loop? so that I could manipulate every field. Thanks in advance sir.
Silver Lightning
13-Feb-11 19:51pm
View
Ok sir thank you very much. :)
Silver Lightning
13-Feb-11 19:24pm
View
Good day Sir Henry,
Do you have any idea or sample code in C# on how could I revise or update this code in converting text file to excel in proper format (with header and proper column)? the code below converts text file to excel file but I need the clear output in excel file in a standard format by column. Here's the sample text file data input and my code.
Here's my sample text file: (fixed space)
tag ord_no ref_no prog_no prog_date acv_type_id
--- ------- ------- ---------- ------------------- -----------
DL 6636500 1 11 Feb 3 2011 11:11AM DLINSTLN
DL 6649978 1 8 Feb 4 2011 12:29PM DLINSTLN
DL 6722809 1 3 Feb 2 2011 5:35PM DLINSTLN
Here's my sample code below sir:
private void Convert_TextFile_To_ExcelFile()
{
// Open the text file in Excel.
m_objExcel = new Microsoft.Office.Interop.Excel.Application();
m_objBooks = (Microsoft.Office.Interop.Excel.Workbooks)m_objExcel.Workbooks;
m_objBooks.OpenText(m_strSampleFolder + "sampledoc.txt",
Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, 1,
Microsoft.Office.Interop.Excel.XlTextParsingType.xlDelimited,
Microsoft.Office.Interop.Excel.XlTextQualifier.xlTextQualifierDoubleQuote,
false, true, false, false, false, false, m_objOpt, m_objOpt,
m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);
m_objBook = m_objExcel.ActiveWorkbook;
// Save the text file in the typical workbook format and quit Excel.
m_objBook.SaveAs(m_strSampleFolder + "sampledoc.xls",
Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal,
m_objOpt, m_objOpt, m_objOpt, m_objOpt,
Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,
m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);
m_objBook.Close(false, m_objOpt, m_objOpt);
m_objExcel.Quit();
Silver Lightning
11-Feb-11 2:04am
View
Thank you sir, but I need to create a program to convert this text file automatically in excel file in a clear format. Thus, do you have an idea on how could I read the text file line by line and by space delimited and convert it to excel file? I need help sir. Thanks
Silver Lightning
11-Feb-11 0:40am
View
Could anyone help me to revise or update this code?. Your help greatly appreciated. Thank you...
Silver Lightning
11-Feb-11 0:09am
View
Hi Sir,
I already got the code on how to convert text file to excel file. But the result was not in a proper format. Can you help me to revise this code on how could I get the header file and body of the data in clear view. Thank you and God bless...
private void Convert_TextFile_To_ExcelFile()
{
// Open the text file in Excel.
m_objExcel = new Microsoft.Office.Interop.Excel.Application();
m_objBooks = (Microsoft.Office.Interop.Excel.Workbooks)m_objExcel.Workbooks;
m_objBooks.OpenText(m_strSampleFolder + "sampledoc.txt",
Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, 1,
Microsoft.Office.Interop.Excel.XlTextParsingType.xlDelimited,
Microsoft.Office.Interop.Excel.XlTextQualifier.xlTextQualifierDoubleQuote,
false, true, false, false, false, false, m_objOpt, m_objOpt,
m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);
m_objBook = m_objExcel.ActiveWorkbook;
// Save the text file in the typical workbook format and quit Excel.
m_objBook.SaveAs(m_strSampleFolder + "sampledoc.xls",
Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal,
m_objOpt, m_objOpt, m_objOpt, m_objOpt,
Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,
m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);
m_objBook.Close(false, m_objOpt, m_objOpt);
m_objExcel.Quit();
}
Silver Lightning
9-Feb-11 22:40pm
View
thanks sir, but I need to automate the conversion of text files to excel file. Can you give me a simple code on how could I do it? Thank you and God bless...
Silver Lightning
9-Feb-11 22:29pm
View
Hi sir, the sample code in link have a lot of invalid tokens. can you give me a sample code that I easily to understand? sorry for disturbing you sir. but I need it urgently. Your help really appreciated.
Silver Lightning
9-Feb-11 21:52pm
View
thank you sir, but how could I reformat (needed) all the fields from text file to excel file?
Silver Lightning
3-Feb-11 21:16pm
View
Thanks you sir. :)
Silver Lightning
3-Feb-11 21:03pm
View
Opps sorry sir Henry. Your code really helps me. Can I ask one more? how can I or What would I use to automate this program just like an scheduler program that would get this text files daily? sorry for disturbing you sir, just I need it urgent. (just give a sample or pattern code for this in c#. Thank you and God bless =)
Silver Lightning
3-Feb-11 20:30pm
View
Hi Sir Henry,
Thanks for the answer but, how could I organize and determine the text files to be copied in by weekly and daily to be saved in particular folder?
Show More