It has been a while since I created the code, and I don't recall why I took that approach, but I can give the UsedRange 'method' a try. Thank you for your reply. WHEELS
Wheels012
Posts
-
Issues with using C# library in Excel 2007 VBA -
Issues with using C# library in Excel 2007 VBAGood morning. I have created a library of functions in C#, and I am testing them to see if they work in both VBA and on a spreadsheet (I am ok if they only work in VBA). I have C# code to display the LastColumn and the LastRow in a spreadsheet as follows:
///
/// Finds the last column on a worksheet.
///
///
///
public string FindLastColumn(Worksheet xlWorkSheet)
{
int nInLastCol = 0;// Find the last real column
nInLastCol = xlWorkSheet.Cells.Find("*", System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, XlSearchOrder.xlByColumns,XlSearchDirection.xlPrevious,
false,System.Reflection.Missing.Value,System.Reflection.Missing.Value).Column;return GetExcelColumnName(nInLastCol);
}///
/// Converts the column # to the corresponding letter.
///
///
///
private string GetExcelColumnName(int columnNumber)
{
int dividend = columnNumber;
string columnName = String.Empty;
int modulo;while (dividend > 0)
{
modulo = (dividend - 1) % 26;
columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
dividend = (int)((dividend - modulo) / 26);
}return columnName;
}///
/// Finds the last row on a worksheet.
///
///
///
public long FindLastRow(Worksheet xlWorkSheet)
{
long nInLastRow = 0;// Find the last real row
nInLastRow = xlWorkSheet.Cells.Find("*", System.Reflection.Missing.Value,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
XlSearchOrder.xlByRows,XlSearchDirection.xlPrevious,
false,System.Reflection.Missing.Value,System.Reflection.Missing.Value).Row;
return nInLastRow;
}The FindLastColumn code works in VBA, but the FindLastRow does not, and neither works on a sheet (not sure how to correctly pass in the current sheet). The error is: Function or interface marked as retricted, or the function uses an Automation type not supported in Visual Basic. VBA:
Dim TSExcelLib As New TechSolutionsXLLibrary.ExcelFunctions
Private Sub CommandButton1_Click()
MsgBox TSExcelLib.FindLastColumn(Sheets("Sheet1")) 'Works
MsgBox TSExcelLib.FindLastColumn(Sheet1) 'WorksMsgBox TSExcelLib.FindLastColumn(Sheets("Sheet1")) 'Doesn't work
MsgBox TSExcelLib.FindLastColumn(Sheet1) 'Doesn't work -
Reading connection string from App.config using LINQThat is a good idea. I'll give it a shot. Thank you.
-
Reading connection string from App.config using LINQGood morning. I am having a challenge deriving a connection string from my App.config. It is laid out for a special way of connection to SQL Server and Teradata, and using AppSettings is not possible. I would like to query for the value using LINQ or Lamda, but I don't have a great deal of experience in either.
-
Adding a hyperlink to a sentence of text in a bulleted listThanks for the help. We'll keeping working on it after the weekend.
-
Adding a hyperlink to a sentence of text in a bulleted listThe bullet rendered, but nothing else.
-
Adding a hyperlink to a sentence of text in a bulleted listWhat property do I use in liBullet? There doesn't seem to be a text property, and innertext didn't work.
-
Adding a hyperlink to a sentence of text in a bulleted listI have to declare the* id, and protected System.Web.UI.WebControls.ListItem liBullets; is incorrect. That appears to be reserved for drop-down or list boxes. I'm not sure what type the
- is to be decalred as.
-
Adding a hyperlink to a sentence of text in a bulleted listprotected System.Web.UI.WebControls.ListItem liBullets;
private const string BULLETTHREELBHL = "Employee earnings can be submitted through the <a href=\"/EECHG/FW_DEFAULT.ASPX?Serviceid=EECHG&title=Employee+Changes\">Employee Changes</a> service by a plan administrator with access to update employee changes.";
this.liBullets.Text = BULLETTHREELBHL;
<ul>
<li id="liBullets" />
<li>To Access Google, click <a href="http://google.com">here</a></li>
<li><a href="http://bing.com">This</a> takes you to Bing</li>
</ul> -
Adding a hyperlink to a sentence of text in a bulleted listWhen I dynamically populate the .text property, I get an Object reference not set to an instance of an object error. System.NullReferenceException.
-
Adding a hyperlink to a sentence of text in a bulleted list<ul>
<li id="liBullet" />
<li><a href="http://bing.com">This</a> takes you to Bing</li>
</ul>C#
protected System.Web.UI.WebControls.ListItem liBullet;
this.liBullet.Attributes.Add(BULLETTHREELBHL);
private const string BULLETTHREELBHL = "Employee earnings can be submitted through the <a href=\"/EECHG/FW_DEFAULT.ASPX?Serviceid=EECHG&title=Employee+Changes\">Employee Changes</a> service by a plan administrator with access to update employee changes.";WHEELS
-
Adding a hyperlink to a sentence of text in a bulleted listIt seems to work well in the .aspx, but now I have to put it in as a dynamic variable. Is there any issue with including the a href in the string? WHEELS
-
Adding a hyperlink to a sentence of text in a bulleted listSorry Shameel. I was not entirely clear. I have done that sucessfully, but what I am looking for is the following: * This is an example of programming. Then when you click the underlined word good it takes you to http://www.codeproject.com. * is a bullet. WHEELS
-
Adding a hyperlink to a sentence of text in a bulleted listI had to abandon the Common control approach. I added a simple BulletedList to the .aspx file, but I am still having a very challenging time setting a hyperlink on a given word in a bullet sentence. I am starting to believe this can't be done. There are three DisplayMode options for a BulletedList: Text, HyperLink, and ImageButton, but no Text/Hyperlink combo. If you have time can you try to create one that does what I am looking for? Thanks, WHEELS
-
Adding a hyperlink to a sentence of text in a bulleted listHi Shameel. The text renders correctly when set up as a label directly on the page. I believe you are correct about the encoding issue. Is there a way to decode? WHEELS
-
Adding a hyperlink to a sentence of text in a bulleted listThanks Bob and Shameel. We had done some modifications to this code and when we put it back, we must have put the syntax back incorrectly. Unfortunately after fixing the code, it still renders as text. WHEELS
-
Adding a hyperlink to a sentence of text in a bulleted listHi Bob. What should they be? WHEELS
-
Adding a hyperlink to a sentence of text in a bulleted listprivate const string BULLETTHREELBHL = "This is an example of the hyperlink <a href=\"/../Test/FW_DEFAULT.ASPX?Serviceid=Test&title=Test+Page>Test Page\"</a> where people click to navigate to another page.";
-
Adding a hyperlink to a sentence of text in a bulleted listGood afternoon. We created a control (somecontrol.cs) which displays a dynamic bullet list. In some scenerios, one of the bullets will have a hyperlink. The problem is, the a href code renders as text. We are adding to a string List and using it as the DataSource for the bulleted list:
private BulletedList _blConfirmText = new BulletedList();
List<string> displayText = new List<string>();
_confirmText.Text = CONFIRMTEXTLB;
displayText.Add(BULLETONELB);
displayText.Add(BULLETTWOLB);if (hasUpdateAccess) displayText.Add(BULLETTHREELBHL); else displayText.Add(BULLETTHREELB);
//set the bullet style and load the bulletd list
_blConfirmText.CssClass = "bulletItems";
_blConfirmText.DataSource = displayText;
_blConfirmText.DataBind();Any idea how to get this to render correctly? Any suggestions? Thank you, WHEELS
-
C# XML Query Website address based on Website nameExcellent. That does the trick. Thank you.