Vyoms OneStopTesting.com - Testing EBooks, Tutorials, Articles, Jobs, Training Institutes etc.
OneStopGate.com - Gate EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopMBA.com - MBA EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopIAS.com - IAS EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopSAP.com - SAP EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopGRE.com - of GRE EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
Bookmark and Share Rss Feeds

How to Realize Bookmark Function in Excel | Articles | Recent Articles | News Article | Interesting Articles | Technology Articles | Articles On Education | Articles On Corporate | Company Articles | College Articles | Articles on Recession
Sponsored Ads
Hot Jobs
Fresher Jobs
Experienced Jobs
Government Jobs
Walkin Jobs
Placement Section
Company Profiles
Interview Questions
Placement Papers
Resources @ VYOMS
Companies In India
Consultants In India
Colleges In India
Exams In India
Latest Results
Notifications In India
Call Centers In India
Training Institutes In India
Job Communities In India
Courses In India
Jobs by Keyskills
Jobs by Functional Areas
Learn @ VYOMS
GATE Preparation
GRE Preparation
GMAT Preparation
IAS Preparation
SAP Preparation
Testing Preparation
MBA Preparation
News @ VYOMS
Freshers News
Job Articles
Latest News
India News Network
Interview Ebook
Get 30,000+ Interview Questions & Answers in an eBook.
Interview Success Kit - Get Success in Job Interviews
  • 30,000+ Interview Questions
  • Most Questions Answered
  • 5 FREE Bonuses
  • Free Upgrades

VYOMS TOP EMPLOYERS

Wipro Technologies
Tata Consultancy Services
Accenture
IBM
Satyam
Genpact
Cognizant Technologies

Home » Articles » How to Realize Bookmark Function in Excel

How to Realize Bookmark Function in Excel








Article Posted On Date : Thursday, March 22, 2012


How to Realize Bookmark Function in Excel
Advertisements

Bookmark Brief Introduction

In different environments, bookmark have different definitions. When reading a book, a bookmark is a piece of paper which is inserted in a book to record which page we have read to. When browsing websites, we can add some interesting and useful webpages as bookmarks to conveniently and quickly return another time. In MS Office, a bookmark is a function to help users go to a specified location quickly and easily. This article focuses on how to realize a bookmark function in MS Excel.

Preparation

In my example, I prepare two workbooks.

Workbook 1

This workbook is a sales report. It includes many worksheets. From worksheet 2 to 6, it shows vendor sales reports, while the latter worksheets show a commission report.

Vendor sales information includes two parts, Parts and Orders. Orders information is related to Parts. For example, the fourth worksheet shows orders information about PartNo K01-07. Commission report includes information in year 2010 and 2011.

Workbook 2

This workbook just has only one worksheet which saves information about staff.

Bookmark List

What I will do is to create a bookmark in the first worksheet of Workbook 1. There are five main bookmark titles, vendor sales report, 2010 commission report, 2011 commission report, Staff information and e-iceblue (a website). Also, I set some other vice bookmark titles under the main bookmarks.

The effect will be as in the following image:

bookmark list.pngpartinfo.png

Step

1. Write sub-methods for calling them in main method.

DrawInternalHyperlink

If we want to move to other worksheets once clicking relevant bookmark title, we need to draw hyperlink for titles. Select bookmark range and add hyperlink in worksheet. Then, set type. Because the bookmark points to internal worksheet, so set type as workbook. Finally, set hyperlink text and jump to where after clicking it.

        static private void DrawInternalHyperlink(Worksheet sheetSource, Worksheet sheetDest, int rowIndex,string text)
        {
            CellRange range = sheetSource.Range[rowIndex, 2];
            HyperLink hyperlink = sheetSource.HyperLinks.Add(range);
            hyperlink.Type = HyperLinkType.Workbook;
            hyperlink.Address = text;
            hyperlink.SubAddress = sheetDest.Range["A1"].RangeGlobalAddress;

        }

DrawExternalHyperlink

The fourth bookmark title points to Workbook 2, so set external hyperlink. Also, select range, add hyperlink and set hyperlink type as file. After setting text, add file path.

        static private void DrawExternalHyperlink(Worksheet sheetSource, int rowIndex, string text)
        {
            CellRange range = sheetSource.Range[rowIndex, 2];
            HyperLink hyperlink = sheetSource.HyperLinks.Add(range);
            hyperlink.Type = HyperLinkType.File;
            hyperlink.TextToDisplay = text;
            hyperlink.Address = @"C:UserslenovoDesktopookmarkookmarkStaffInfo.xlsx";
        }

DrawUrlHyperlink

The fifth bookmark title moves us to a website, so draw url hyperlink. Select range, add hyperlink and set hyperlink type as url. Add text and website address.

        static private void DrawUrlHyperlink(Worksheet sheetSource,int rowIndex,string url)
        {
            CellRange range = sheetSource.Range[rowIndex, 2];
            HyperLink hyperlink = sheetSource.HyperLinks.Add(range);
            hyperlink.Type = HyperLinkType.Url;
            hyperlink.TextToDisplay = "5   E-iceblue";
            hyperlink.Address = url;
        }

SetFormat

This method is used to set bookmark list format, including font style, background color and indentation.

        static private void SetFormat(Worksheet sheet, int rowIndex,float fontSize,int indent)
        {
            sheet.Range[rowIndex, 2].Style.Font.Size = fontSize;
            sheet.Range[rowIndex, 2].Style.Font.IsBold = true;
            sheet.Range[rowIndex, 2].Style.IndentLevel = indent;
            sheet.Range[rowIndex, 2].Style.Font.Color = Color.AliceBlue;
            sheet.Range[rowIndex, 2].Style.Font.FontName = "Calibri";
            sheet.Range[rowIndex, 2].Style.Color = Color.LightSkyBlue;
        }

2. Load file from computer and set source sheet. Then, define rowindex initial value, which means that the bookmark list will be input from which row.

            Workbook workbook = new Workbook();
            workbook.LoadFromFile(@"....ookmark list.xlsx", ExcelVersion.Version2010);
            Worksheet sheetSource = workbook.Worksheets[0];
            int rowIndex = 2;

3. Draw bookmark list 1. Bookmark list 1 includes one main bookmark, two sub-bookmarks and two third-bookmarks. The main bookmark is linked to worksheet 2. The two sub-bookmarks are linked to worksheet 2 and 4 respectively. The two third-bookmarks are linked to worksheet 3 and 5. All the bookmark titles are worksheet name.

            DrawInternalHyperlink(sheetSource, workbook.Worksheets[1], rowIndex++,String.Format("1   {0}",workbook.Worksheets[1].Name));
            SetFormat(sheetSource, 2, 13,0);

            DrawInternalHyperlink(sheetSource, workbook.Worksheets[2], rowIndex++,String.Format("1.1  {0}", workbook.Worksheets[2].Name));
            SetFormat(sheetSource, 3, 12,4);

            DrawInternalHyperlink(sheetSource, workbook.Worksheets[3], rowIndex++, String.Format("1.1.1  {0}",workbook.Worksheets[3].Name));

      SetFormat(sheetSource, 4, 11,8);
 

      DrawInternalHyperlink(sheetSource, workbook.Worksheets[4], rowIndex++,  String.Format("1.2   {0}", workbook.Worksheets[4].Name));

      SetFormat(sheetSource, 5, 12,4);
 

      DrawInternalHyperlink(sheetSource, workbook.Worksheets[5], rowIndex++,  String.Format("1.2.1  {0}",workbook.Worksheets[5].Name));

      SetFormat(sheetSource, 6, 11,8);


4. Draw bookmark list 2 and 3. Bookmark list 2 and 3 also point to worksheets in Workbook 1. Therefore, draw it as the above step.

          
      DrawInternalHyperlink(sheetSource, workbook.Worksheets[6], rowIndex++, String.Format("2   {0}", workbook.Worksheets[6].Name));

      SetFormat(sheetSource, 7, 13,0);

 

      DrawInternalHyperlink(sheetSource, workbook.Worksheets[7], rowIndex++, String.Format("2.1   {0}", workbook.Worksheets[7].Name));

      SetFormat(sheetSource, 8, 12,4);
 

      DrawInternalHyperlink(sheetSource, workbook.Worksheets[8], rowIndex++, String.Format("2.2   {0}", workbook.Worksheets[8].Name));

      SetFormat(sheetSource, 9, 12,4);

 

      DrawInternalHyperlink(sheetSource, workbook.Worksheets[9], rowIndex++, String.Format("3   {0}", workbook.Worksheets[9].Name));

      SetFormat(sheetSource, 10, 13,0);

 

      DrawInternalHyperlink(sheetSource, workbook.Worksheets[10], rowIndex++, String.Format("3.1   {0}", workbook.Worksheets[10].Name));

      SetFormat(sheetSource, 11, 12,2);

      DrawInternalHyperlink(sheetSource, workbook.Worksheets[11], rowIndex++, String.Format("3.2   {0}", workbook.Worksheets[11].Name));

      SetFormat(sheetSource, 12, 12,2);

 

5. Draw bookmark list 4. Bookmark list 4 is linked to Workbook 2. Set its location, title and format.


      DrawExternalHyperlink(sheetSource, rowIndex++, "4   StaffInfo.xlsx");

      SetFormat(sheetSource, 13, 13,0);
 

6. Draw bookmark list 5. Bookmark list 5 is linked to a website. Set its location and add site address. Then set format.

 

      DrawUrlHyperlink(sheetSource, rowIndex++, "http://www.e-iceblue.com");

      SetFormat(sheetSource, 14, 13,0);

 

7. Set column width and row height.
 

      sheetSource.AllocatedRange.AutoFitColumns();

      sheetSource.AllocatedRange.RowHeight = 18;
 

8. Save and launch file
 

      workbook.SaveToFile(@".... esult.xlsx", ExcelVersion.Version2010);

      System.Diagnostics.Process.Start(@".... esult.xlsx");

Conclusion

In this article, I show a method about how to realize bookmark function in MS Excel. The bookmark can point to worksheet in one workbook, in other workbook and website. After clicking bookmark title, we can get the relevant contents about this title shows.

Note: Spire.XLS is used in this method to help me realize this function.






Sponsored Ads



Interview Questions
HR Interview Questions
Testing Interview Questions
SAP Interview Questions
Business Intelligence Interview Questions
Call Center Interview Questions

Databases

Clipper Interview Questions
DBA Interview Questions
Firebird Interview Questions
Hierarchical Interview Questions
Informix Interview Questions
Microsoft Access Interview Questions
MS SqlServer Interview Questions
MYSQL Interview Questions
Network Interview Questions
Object Relational Interview Questions
PL/SQL Interview Questions
PostgreSQL Interview Questions
Progress Interview Questions
Relational Interview Questions
SQL Interview Questions
SQL Server Interview Questions
Stored Procedures Interview Questions
Sybase Interview Questions
Teradata Interview Questions

Microsof Technologies

.Net Database Interview Questions
.Net Deployement Interview Questions
ADO.NET Interview Questions
ADO.NET 2.0 Interview Questions
Architecture Interview Questions
ASP Interview Questions
ASP.NET Interview Questions
ASP.NET 2.0 Interview Questions
C# Interview Questions
Csharp Interview Questions
DataGrid Interview Questions
DotNet Interview Questions
Microsoft Basics Interview Questions
Microsoft.NET Interview Questions
Microsoft.NET 2.0 Interview Questions
Share Point Interview Questions
Silverlight Interview Questions
VB.NET Interview Questions
VC++ Interview Questions
Visual Basic Interview Questions

Java / J2EE

Applet Interview Questions
Core Java Interview Questions
Eclipse Interview Questions
EJB Interview Questions
Hibernate Interview Questions
J2ME Interview Questions
J2SE Interview Questions
Java Interview Questions
Java Beans Interview Questions
Java Patterns Interview Questions
Java Security Interview Questions
Java Swing Interview Questions
JBOSS Interview Questions
JDBC Interview Questions
JMS Interview Questions
JSF Interview Questions
JSP Interview Questions
RMI Interview Questions
Servlet Interview Questions
Socket Programming Interview Questions
Springs Interview Questions
Struts Interview Questions
Web Sphere Interview Questions

Programming Languages

C Interview Questions
C++ Interview Questions
CGI Interview Questions
Delphi Interview Questions
Fortran Interview Questions
ILU Interview Questions
LISP Interview Questions
Pascal Interview Questions
Perl Interview Questions
PHP Interview Questions
Ruby Interview Questions
Signature Interview Questions
UML Interview Questions
VBA Interview Questions
Windows Interview Questions
Mainframe Interview Questions


Copyright © 2001-2024 Vyoms.com. All Rights Reserved. Home | About Us | Advertise With Vyoms.com | Jobs | Contact Us | Feedback | Link to Us | Privacy Policy | Terms & Conditions
Placement Papers | Get Your Free Website | IAS Preparation | C++ Interview Questions | C Interview Questions | Report a Bug | Romantic Shayari | CAT 2024

Fresher Jobs | Experienced Jobs | Government Jobs | Walkin Jobs | Company Profiles | Interview Questions | Placement Papers | Companies In India | Consultants In India | Colleges In India | Exams In India | Latest Results | Notifications In India | Call Centers In India | Training Institutes In India | Job Communities In India | Courses In India | Jobs by Keyskills | Jobs by Functional Areas

Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes

Gate Articles | Gate Books | Gate Colleges | Gate Downloads | Gate Faqs | Gate Jobs | Gate News | Gate Sample Papers | Gate Training Institutes

MBA Articles | MBA Books | MBA Case Studies | MBA Business Schools | MBA Current Affairs | MBA Downloads | MBA Events | MBA Notifications | MBA FAQs | MBA Jobs
MBA Job Consultants | MBA News | MBA Results | MBA Courses | MBA Sample Papers | MBA Interview Questions | MBA Training Institutes

GRE Articles | GRE Books | GRE Colleges | GRE Downloads | GRE Events | GRE FAQs | GRE News | GRE Training Institutes | GRE Sample Papers

IAS Articles | IAS Books | IAS Current Affairs | IAS Downloads | IAS Events | IAS FAQs | IAS News | IAS Notifications | IAS UPSC Jobs | IAS Previous Question Papers
IAS Results | IAS Sample Papers | IAS Interview Questions | IAS Training Institutes | IAS Toppers Interview

SAP Articles | SAP Books | SAP Certifications | SAP Companies | SAP Study Materials | SAP Events | SAP FAQs | SAP Jobs | SAP Job Consultants
SAP Links | SAP News | SAP Sample Papers | SAP Interview Questions | SAP Training Institutes |


Copyright ©2001-2024 Vyoms.com, All Rights Reserved.
Disclaimer: VYOMS.com has taken all reasonable steps to ensure that information on this site is authentic. Applicants are advised to research bonafides of advertisers independently. VYOMS.com shall not have any responsibility in this regard.