Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
Questionlock block with parameter Pin
Atul Kharecha17-Sep-09 19:16
Atul Kharecha17-Sep-09 19:16 
AnswerRe: lock block with parameter Pin
PIEBALDconsult17-Sep-09 19:31
mvePIEBALDconsult17-Sep-09 19:31 
GeneralRe: lock block with parameter Pin
Atul Kharecha17-Sep-09 19:41
Atul Kharecha17-Sep-09 19:41 
GeneralRe: lock block with parameter Pin
OriginalGriff17-Sep-09 22:02
mveOriginalGriff17-Sep-09 22:02 
GeneralRe: lock block with parameter Pin
Atul Kharecha17-Sep-09 23:23
Atul Kharecha17-Sep-09 23:23 
GeneralRe: lock block with parameter Pin
OriginalGriff18-Sep-09 0:28
mveOriginalGriff18-Sep-09 0:28 
AnswerRe: lock block with parameter Pin
Nicholas Butler17-Sep-09 22:13
sitebuilderNicholas Butler17-Sep-09 22:13 
Questionhelp on C# EXCEL Pin
gjx_junxian198917-Sep-09 16:29
gjx_junxian198917-Sep-09 16:29 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Excel;
using System.Windows.Forms;
using System.Reflection;


namespace testtesttestExcel
{
public partial class Form1 : Form
{
public Form1()

{
InitializeComponent();
}


//Declare these two variables globally so you can access them from both
//Button1 and Button2.
Microsoft.Office.Interop.Excel.Application objApp;
Microsoft.Office.Interop.Excel._Workbook objBook;

Microsoft.Office.Interop.Excel.Workbooks objBooks;
Microsoft.Office.Interop.Excel.Sheets objSheets;
Microsoft.Office.Interop.Excel._Worksheet objSheet;
Microsoft.Office.Interop.Excel.Range range;


private void button1_Click(object sender, System.EventArgs e)
{

try
{
// Instantiate Excel and start a new workbook.
objApp = new Microsoft.Office.Interop.Excel.Application();
objBooks = objApp.Workbooks;
objBook = objBooks.Add(Missing.Value);
objSheets = objBook.Worksheets;
objSheet = (Microsoft.Office.Interop.Excel._Worksheet)objSheets.get_Item(1);

//Get the range where the starting cell has the address
//m_sStartingCell and its dimensions are m_iNumRows x m_iNumCols.
range = objSheet.get_Range("A1", Missing.Value);
range = range.get_Resize(5, 5);

//Create an array.
double[,] saRet = new double[5, 5];

//Fill the array.
for (long iRow = 0; iRow < 5; iRow++)
{
for (long iCol = 0; iCol < 5; iCol++)
{
//Put a counter in the cell.
saRet[iRow, iCol] = iRow * iCol * iCol;
}
}

//Set the range value to the array.
range.set_Value(Missing.Value, saRet);
objApp.Visible = true;
objApp.UserControl = true;

}

catch( Exception theException )
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat( errorMessage, theException.Message );
errorMessage = String.Concat( errorMessage, " Line: " );
errorMessage = String.Concat( errorMessage, theException.Source );

MessageBox.Show( errorMessage, "Error" );
}



Microsoft.Office.Interop.Excel.Range currentFind = null;
Microsoft.Office.Interop.Excel.Range firstFind = null;

string A = "16";

// You should specify all these parameters every time you call this method,
// since they can be overridden in the user interface.
currentFind = objSheet.Cells.Find(A, Type.Missing,
Microsoft.Office.Interop.Excel.XlFindLookIn.xlValues, Microsoft.Office.Interop.Excel.XlLookAt.xlWhole,
Microsoft.Office.Interop.Excel.XlSearchOrder.xlByRows, Microsoft.Office.Interop.Excel.XlSearchDirection.xlNext, false,
Type.Missing, Type.Missing);

while (currentFind != null)
{
// Keep track of the first range you find.
if (firstFind == null)
{
firstFind = currentFind;

//textBox1.Text = currentFind.get_Address(true, true, Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, false, Missing.Value);


}

// If you didn't move to a new range, you are done.
else if (currentFind.get_Address(Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, Type.Missing, Type.Missing)
== firstFind.get_Address(Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, Type.Missing, Type.Missing))
{
break;
}

currentFind.Font.Color = System.Drawing.ColorTranslator.ToOl
(System.Drawing.Color.Red);
currentFind.Font.Bold = true;


currentFind = objSheet.Cells.FindNext(currentFind);
}

}
}



After finding the cell containing "16", i want to write in string data to the right of it. how should i go about doin this. I did some research on the codes, but i kept getting errors. Please advise me on my problem. Thanks alot!!
QuestionGUID Pin
Illegal Operation17-Sep-09 14:39
Illegal Operation17-Sep-09 14:39 
AnswerRe: GUID Pin
PIEBALDconsult17-Sep-09 14:42
mvePIEBALDconsult17-Sep-09 14:42 
GeneralRe: GUID Pin
Illegal Operation17-Sep-09 17:13
Illegal Operation17-Sep-09 17:13 
GeneralRe: GUID Pin
PIEBALDconsult17-Sep-09 19:13
mvePIEBALDconsult17-Sep-09 19:13 
QuestionCopy transparent image to Photoshop Pin
Winkles17-Sep-09 13:04
Winkles17-Sep-09 13:04 
AnswerRe: Copy transparent image to Photoshop Pin
Henry Minute17-Sep-09 14:01
Henry Minute17-Sep-09 14:01 
GeneralRe: Copy transparent image to Photoshop Pin
Winkles17-Sep-09 18:03
Winkles17-Sep-09 18:03 
GeneralRe: Copy transparent image to Photoshop Pin
Henry Minute18-Sep-09 1:05
Henry Minute18-Sep-09 1:05 
QuestionCrystal Reports or RDLC Pin
Jassim Rahma17-Sep-09 11:38
Jassim Rahma17-Sep-09 11:38 
AnswerRe: Crystal Reports or RDLC Pin
egenis17-Sep-09 20:24
egenis17-Sep-09 20:24 
Questionc# back up program ? :S Pin
booo2222222222222217-Sep-09 11:06
booo2222222222222217-Sep-09 11:06 
AnswerRe: c# back up program ? :S Pin
EliottA17-Sep-09 11:16
EliottA17-Sep-09 11:16 
GeneralRe: c# back up program ? :S Pin
booo2222222222222217-Sep-09 11:21
booo2222222222222217-Sep-09 11:21 
GeneralRe: c# back up program ? :S Pin
EliottA17-Sep-09 11:26
EliottA17-Sep-09 11:26 
GeneralRe: c# back up program ? :S Pin
booo2222222222222217-Sep-09 11:38
booo2222222222222217-Sep-09 11:38 
GeneralRe: c# back up program ? :S Pin
Not Active17-Sep-09 11:28
mentorNot Active17-Sep-09 11:28 
GeneralRe: c# back up program ? :S Pin
booo2222222222222217-Sep-09 11:33
booo2222222222222217-Sep-09 11:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.