none
How to select the predefined area as WIDTH in PIXEL by HEIGHT IN PIXELS in MSEXCEL for desiging your templates RRS feed

  • Question

  • Hey

    I am creating my OWN EXCEL PLUGIN 2010 in vb.net for designing purpose. My requirement is in MY EXCEL sheet i want to select the 1028 By 768 pxiles area for designing .

    that area will be calculated automatically on Load of Addin. so that i can start designing in the particular area only.

    That are will be filled with WHITE COLOR.

    and the selected area of 1028 by 768 pixels can be varied upon  my requirement.

    please help me as i am new to office tools.

     


    Thursday, December 15, 2011 7:50 AM

All replies

  • Hey,

    i am creating Excel 2010 Plugin that is an application level project. In which i have to select the particular area in Width in pixels by Height in pixels. then that Area will be painted with WHITE COLOR.

    IS it possible to retrieve the cell Ranges for that selected ARea . Supposing Cell Range Start from A1.

    please help me ..

    As i think that if cell Range can be retrieved for that HEIGHT ND WIDTH, it can be painted with WHITE COLOR and can be used

    for designing purpose.

     




    Friday, December 16, 2011 5:45 AM
  • Hey,

    As i am not having the proper responses of my Previous Post related to this things so i am putting an another posts as above that is it possible to shrink the WHOLE WORKSHEET ACCORDING TO MY REQUIREMENT OF WIDTH AND HEIGHT IN PIXELS.

    So i can fill it white color and can use for desiging purpose according to the selected platform of (WEB/MOBILE/ANDROID) etc.

    I am  developing the EXCEL 2010 ADD-IN and pasted this code just for trial on any button click:

      Dim NativeWorksheet As Microsoft.Office.Interop.Excel.Workbook =
                Globals.ThisAddIn.Application.ActiveWorkbook


                Dim vstoWorksheet As Microsoft.Office.Tools.Excel.Workbook =
                Globals.Factory.GetVstoObject(NativeWorksheet)

                   vstoWorksheet.Application.Width = 1024

    but it raising an error of COM..

     

     

    Friday, December 16, 2011 12:25 PM
  • Hi ArchanaSinghvi,

     

    Thanks for posting in the MSDN Forum.

     

    As far as I know that the rows’ height is count by pixel however I found it has different values on different computer with different Windows which use different culture or Excel version. And cells’ width will related to the default characters width, as default the cell’s width is 8 characters’ width. So I think this is a complex issue for me, I will involve some experts into this issue. I hope them can help you. There might be some time dely. Appreciate your patience.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Monday, December 19, 2011 3:30 AM
    Moderator
  • Hi,

    i will explain you the things one more clear way.

    lets have the snapshot.


    so as per the image , the user will select the GRID SIZE, then template and according to this it will select the WIDTH and HEIGHT in PIXELS.

    so the CELL WIDTH AND HEIGHT WILL BE ADJUSTED EQUAL TO GRID SIZE IN PIXELS.

    and then it will CALCULATE THE TOTAL NO OF CELLS FOR THE SELECTED WIDTH AND HEIGHT IN PIXELS.

    SO THAT IT CAN PAINT THOESE CELLS ONLY IN WHITE COLOR FOR STARTING DESIGNING.

    LETS SUPPOSE IT WILL SELECT THE CELLS STRATING FROM A1 to equal to that width and height in pixels.

    YOU CAN UNDERSTAND IT AS in non technical term YOU have a big RECTANGLE and you have to draw a small rectangle in it  for particular width and height.

     please see how it will happen


    Are you able to see the above screen , the result will come in this form. The particular cells are counted on the BASIS OF grid SIZE, WIDTH AND HEIGHT in pixels are painted WHITE . REST CELLS ARE SAME.

    MAY BE i am not that much technical expert in telling you the techy things but this is my requirement.

    Please help me so that i can proceed ahaed.

     


    Monday, December 19, 2011 5:21 AM
  • Hello Archana Singhvi,

    In your first post you ask “Is it possible to retrieve the cell Ranges for that selected area.?”

    Possible is an intimidating word – yes, it is possible if you can control everything. Based upon the resolution of the display, the version of Excel, the default font, and the presumption that the end-user hasn’t done anything with the new workbook you can calculate the number of rows and columns based upon the default values of column-width and row-height. On Excel 2010 the default row height is 15 points.  The default column width is 8.43 points. A point is 1/72th of an inch. Based on screen resolution you can determine how many pixels are in a cell.

    The end user can drag the border between columns to fit a value beyond the range you want. That changes the width of the entire column. Dragging a column does not fire an event so you won’t be able to programmatically set it back. The end-user can also hide a column.

    The end-user can also drag the bottom border of a cell down or push it up, thus changing the row-height.

    Undoubtedly you have invested much time in designing your application. Within the bounds of reasonableness your design can’t be implemented in the way you choose.  Does the area have to be the fixed size of 1028 x 768?

    Could you use a user form instead? You can make the form Modal so that it is on top of the Excel sheet until released by either the end-user through a button-click, or programmatically based on what the end-user enters in controls (e.g. textbox or ComboBox) on the form?

    In VKB you can query on the argument ‘User form and Excel’ to  get an extensive result set of links to content on UserForms.

    Please “Mark as anser” if this information helps answer your question.

    Regards,
    Chris Jensen
    Senior Technical Support Lead

    Monday, December 19, 2011 9:24 PM
    Moderator
  • Hello Archana Singhvi,

    Here are leads to more information about row heights and column widths, and I need to correct myself about column width – the default value for column width is 8.35 characters, not points.

    RowHeight Property
    http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.namedrange.rowheight(v=VS.80).aspx

    row height - Support - Office.com
    http://office.microsoft.com/en-us/help/CH010245997.aspx

    Change column width and row height - Excel - Office.com
    http://office.microsoft.com/en-us/excel-help/change-column-width-and-row-height-HP005198813.aspx

    A possible approach to your project is to arbitrarily define a named-range and set the row heights and column widths so their combined sizes will be the dimensions you want.  You would still need to transform those sizes into pixels. Here is the VB code to set the sizes in a named range :

    Microsoft.Office.Tools.Excel.NamedRange setColumnRowRange;

    private void SetColumnAndRowSizes()

    {

        setColumnRowRange = this.Controls.AddNamedRange(

            this.Range["C3", "E6"], "setColumnRowRange");

        this.setColumnRowRange.ColumnWidth = 20;

        this.setColumnRowRange.RowHeight = 25;

        setColumnRowRange.Select();

    }

    Please “Mark as answer” if this information helps solve your problem.

    Regards,
    Chris Jensen
    Senior Technical Support Lead

    Wednesday, December 21, 2011 2:28 PM
    Moderator
  • i have calculated it with some formulas.
    Monday, December 26, 2011 5:13 AM