ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  VB.NET
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions
 C Sharp interview questions  C Sharp Interview Questions
 ASP.NET interview questions  ASP.NET Interview Questions
 VB.NET interview questions  VB.NET Interview Questions
 COM+ interview questions  COM+ Interview Questions
 ADO.NET interview questions  ADO.NET Interview Questions
 IIS interview questions  IIS Interview Questions
 MTS interview questions  MTS Interview Questions
 Crystal Reports interview questions  Crystal Reports Interview Questions
 BizTalk interview questions  BizTalk Interview Questions
 Dot Net interview questions  Dot Net Interview Questions
 Exchange Server interview questions  Exchange Server Interview Questions
 SharePoint interview questions  SharePoint Interview Questions
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
in my windows application i have to show excelwork 
sheetwhich is stored in the local system can any one tell 
me the code?
 Question Submitted By :: Savikumar7
I also faced this Question!!     Rank Answer Posted By  
 
  Re: in my windows application i have to show excelwork sheetwhich is stored in the local system can any one tell me the code?
Answer
# 1
I'm giving you the code about export to excel i.e., now i'm 
taking table from database and binding to excel sheet.That 
Excel sheel is on my Local System.
Here i'm using Aspose(its a 3rd Party Tool)
Aspose reduces the code by setting data ,cells etc in Excel 
Sheet.
Its a WebApplication.U can change it to Windows Application.

This code is for Setting the format for Excel Sheet:
public Workbook ExportToExcel(DataSet objDs, string 
strHeader)
        {
            DataTable dtResult;
            dtResult = objDs.Tables[0];

            Workbook excel = new Workbook();
            excel.Worksheets[0].Name = strHeader;

            #region SettingHeaderInformation

            excel.Worksheets[0].Cells
["B4"].Style.Font.IsBold = true;
            excel.Worksheets[0].Cells["B4"].Style.Font.Size 
= 12;
            excel.Worksheets[0].Cells["B4"].PutValue
(strHeader);

            excel.Worksheets[0].Cells
["D4"].Style.Font.IsItalic = true;
            excel.Worksheets[0].Cells["D4"].PutValue
("Dated: " + DateTime.Now.ToLongDateString());

            #endregion

            //Exports data set into excel cells
            Aspose.Cells.Cells exportCells = 
excel.Worksheets[0].Cells;
            exportCells.ImportDataTable(dtResult, false, 5, 
0);

            //This block is to header for exported data 
table.
            Aspose.Cells.Cells sheetCell = excel.Worksheets
[0].Cells;
            for (int i = 0; i < dtResult.Columns.Count; i++)
            {
                if (i != (objDs.Tables[0].Columns.Count - 
1))
                    excel.Worksheets[0].AutoFitColumn(i);

                excel.Worksheets[0].Cells[5, 
i].Style.Number = 49;
                excel.Worksheets[0].Cells[5, 
i].Style.Pattern = BackgroundType.Solid;
                excel.Worksheets[0].Cells[5, 
i].Style.ForegroundColor = excel.GetMatchingColor
(Color.FromName(SystemColors.InactiveCaption.Name));
                excel.Worksheets[0].Cells[5, 
i].Style.Font.IsBold = true;
                excel.Worksheets[0].Cells[5, 
i].Style.Font.Color = Color.White;
                string headerTxt = dtResult.Columns
[i].ColumnName;
                if (headerTxt.Contains(strDesc))
                    headerTxt = headerTxt.Remove
(headerTxt.IndexOf(strDesc));
                else if (headerTxt.Contains(strDesc))
                    headerTxt = headerTxt.Remove
(headerTxt.IndexOf(strDesc));
                excel.Worksheets[0].Cells[5, i].PutValue
(headerTxt);
                if (i < objDs.Tables[0].Columns.Count)
                    excel.Worksheets[0].Cells[5, 
i].Style.HorizontalAlignment = TextAlignmentType.Left;
                else
                    excel.Worksheets[0].Cells[5, 
i].Style.HorizontalAlignment = TextAlignmentType.Right;
            }

            return excel;
        }


In Button we can write this code(its for binding the data 
from database to Excel Sheet):

 protected void Button2_Click(object sender, EventArgs e)
    {
        Aspose.Cells.Workbook workBook = new 
Aspose.Cells.Workbook();
        ExportMethods objExpMethods = new ExportMethods();
        ds = objclass.getpagebal();//calling function from 
businesslayer(table)
        workBook = objExpMethods.ExportToExcel
(ds, "shanti_emp");//shanti_emp is a table name
        workBook.Save("shantiExcel.xls", 
FileFormatType.Default, 
Aspose.Cells.SaveType.OpenInBrowser, Response);
    }

U can convert it according to your convineince.
 
Is This Answer Correct ?    0 Yes 2 No
Prashanthi
 

 
 
 
Other VB.NET Interview Questions
 
  Question Asked @ Answers
 
how to call a list box on the text if some one send me the code for it  1
what is vb.net?  9
what is the base class of .net?  6
What is the difference between Dataset and Recordset?  7
Disadvantages of vb ? Digital-GlobalSoft4
In Datagrid after adding row, how you will assign the value for each cell to currently added new row?  1
what is the root namespace for all types?  5
How does you get record no from 5 to 15 from a dataset of 100 records? ABC2
when we will use console ?  3
I want to reduce my CPU Usage when I am querying the Database for records. Now my Winform App(in VB.Net) suddenly Jumps to 100% CPU Usage when i query for records from sql server database. I want this Usage to be less. Any help is appreciated  2
In order to get assembly info whcih namespace we should import?  1
ColumnMapping belongs to which namespaces?  1
How do you rate yourself in .NET ? Infosys3
hello friends, I have created a animated button in VB.NET. As its dll file coding can be viewed and also copied to some other location. So my question is how can I protect the Dll file of the animated button so that noone can access it. Any idea about this???????? Thanks Rekha  1
when a program of vb.net is written in notepad it occupies always 1kb of memory why?  1
Display a roll having minimum marks in two subjects? Patni1
In vb.net how to connect crystal report?  1
how to connect crystal report with vb.net ? Patni2
What is intermediate language in .NET ? Digital-GlobalSoft13
What does VS.NET contains ? Infosys3
 
For more VB.NET Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com