Know the Last column of the table

Hello 
i use vb.net with excel
I have a table
with a spreadsheet, I want to know the Last
column of the table 
please help me ??

i have a table in Excel file and i want to add the last column of this table in datagridview 
i want to set ShtRange to give me the last column 
i use this but don't give me a result 
With Form1.xlWorkSheet
Dim ShtRange As Range
Dim dt As New System.Data.DataTable
ShtRange = Form1.xlWorkSheet.Cells(1, Form1.xlWorkSheet.Columns.Count).End(XlDirection.xlToLeft)
For Cnum As Integer = 1 To ShtRange.Columns.Count
dt.Columns.Add(New DataColumn(TryCast(ShtRange.Cells(1, Cnum), Excel.Range).Value.ToString()))
Next
dt.AcceptChanges()
Dim columnNames As String() = New String(dt.Columns.Count - 1) {}
For i As Integer = 0 To dt.Columns.Count - 1
columnNames(0) = dt.Columns(i).ColumnName
Next
For Rnum As Integer = 2 To ShtRange.Rows.Count
Dim dr As DataRow = dt.NewRow()
For Cnum As Integer = 1 To ShtRange.Columns.Count
If TryCast(ShtRange.Cells(Rnum, Cnum), Excel.Range).Value2 IsNot Nothing Then
dr(Cnum - 1) = TryCast(ShtRange.Cells(Rnum, Cnum), Excel.Range).Value2.ToString()
End If
Next
dt.Rows.Add(dr)
dt.AcceptChanges()
Next
Me.DataGridView1.DataSource = dt
End With
this is my table :

Similar Messages

  • Emacs is displaying the first column of the line on the last column of the previous line

    The first column of my lines are being displayed on the last column of the previous line. This a very irritating glitch that I have no clue how to fix or even troubleshoot. (red bars were added using preview to hide personal info)
    I've downloaded MacPorts and reinstalled emacs:
    GNU Emacs 24.4.1
    Copyright (C) 2014 Free Software Foundation, Inc.
    GNU Emacs comes with ABSOLUTELY NO WARRANTY.
    You may redistribute copies of Emacs
    under the terms of the GNU General Public License.
    For more information about these matters, see the file named COPYING.
    I'm open to any suggestions on how to fix this graphical glitch.
    Much thanks
    Message was edited by: Conner_36

    Given that the Emacs for OS X works ok and the Emacs shipped with OS X works it would seem to be some issue with MacPorts and their version.
    Totally unfamiliar with MacPorts so have no idea how the program gets compiled,what libraries it is using and what if any config settings are needs or set so I'm afraid I won;t be much help there.  That you are on a MBP with a retina display may be part of the problem.
    So with the setup you have now, hardware and software including OS,  it was working and then just like that it stopped? Something much have changed around the time it stop working if you can think back to then it might help you resolve the problem.
    As you are doing programming can i assume you have Xcode and the command line tools installed? If not how do you compile your code? The reason I ask is compiling Emacs from there GNU source is not all that difficult. It might be worth trying that.
    One last thing given that the two other versions of Emacs displayed the file OK this strongly suggests the problem is not in your .emacs file or your environment however as I wrote I am not familiar with MacPorts so it is possible there is another config file messing you up. As a test for this create a new user or log in as the Guest user (this is best as you;re guaranteed the environment is clean) and look at the file in question in MacPorts Emacs. If it displays OK then there is something in your environment causing this, If it messes up  even in the new user then I'd say ditch MacPorts..
    regards
    <edit>
    Just to rule out init files  if you start emacs with the -q(minus que) flag the .emacs file is not read in, if you use  --no-site-file it will not load the site file if it exists.
    I'd try running the MacPorts emacs with those two flags to see f anything changes.

  • How to get the last column info of the given table

    Hi All,
    I want to get the last column information like :
    column name, datatype of the last column in the given
    table use PL statement. Please help.
    Thanks,
    JP

    SCOTT@orcl SQL> desc emp
    Name                                                  Null?    Type
    EMPNO                                                 NOT NULL NUMBER(4)
    ENAME                                                          VARCHAR2(10)
    JOB                                                            VARCHAR2(9)
    MGR                                                            NUMBER(4)
    HIREDATE                                                       DATE
    SAL                                                            NUMBER(7,2)
    COMM                                                           NUMBER(7,2)
    DEPTNO                                                         NUMBER(2)
    SCOTT@orcl SQL> select column_name, data_type from user_tab_columns
      2  where table_name = 'EMP'
      3  and column_id = (select max(column_id) from user_tab_columns
      4  where table_name = 'EMP');
    COLUMN_NAME                    DATA_TYPE
    DEPTNO                         NUMBER
    SCOTT@orcl SQL>                                                                      

  • Issue with the last column stretching in ADF table

    There is an issue wherein when  I try stretching the last column of the ADF table to reduce its width it does stretch. But whenever I try stretching it back to this original position it doesn't despite having columnstretching attribute set to multiple and assign widths in percentages to columns . When I set the columnstretching attribute to none, the last column does stretch back and forth but on page load the table does not stretch to its full width despite having styleClass="AFStretchWidth". Now I dont want to be assigning fixed width in pixels to the columns. I would want the last column to stretch back and forth with columnstretching="multiple" and styleClass="AFStretchWidth". I see the same issue on components demo page as well. Tag Guide

    If you are trying that each column gets equally stretched based on the browser, its not possible as adf doesn't supports that.
    If your table is not stretching use styleClass="AFStretchWidth".
    But if all your columns are not stretching you can only try setting column widths + columnStretching property (where you can specify which column to stretch to fill all the spaces)
    Amit

  • How do I create a new row on tab out of the last column, last row?

    JDev 11.1.2.1.0.
    I've seen a few topics on this but none that I think were really very good solutions.
    Use Case:
    On tab out of the last column in the last row, a new row should be added to the end of the table. Bonus points for setting the focus to the first <af:inputText> of the newly created row.
    Complications:
    1. I'm having a heck of a time trying to find a function that returns the column's displayed index. Sadly, <column binding>.getDisplayIndex() returns -1 unless the user has manually re-ordered the column.
    2. Value Change Listeners only fire if there is a value change. Guess that means I need to do client/server listeners to check each and every <af:inputText> for a tab press?
    3. I'm not even going to get into setting the focus. With all the templates, regions, etc. going on, it's dang near impossible.
    Any ideas on how to attack this one?
    Will

    Hi,
    You will need to use the Run Engine Installation Wizard found on the Tools menu. In addition you need to create a installation set for the operator interface.
    Look at Chapter 16 Distrubuting TestStand ( chapter 17 for version 2).
    Once you have created your installation, install is on your new system.
    The serial number etc is part of the process model. When you run the entry point 'Test UUTs' the PreUUT callback is executed which asks the user for the serial number.
    Hope this helps
    Ray Farmer
    Regards
    Ray Farmer

  • Finder in column view has no expander divider on the last column

    I deal with a lot of graphics on my computer and I have a lot of subfolders. While in finder in column view there is no expanding divider for the last column when it is showing a graphic. When I first open a photo or graphic in finder the last column shows the graphic smaller than regular size. In SL there was a column divider to expand only that last column so I could make the graphic larger to see it better. Now in Lion there is no divider on the right side of that last column to expand the last column where the grahic is showing. In order for it to finally expand I have to drag the right side of the Finder window all the way across my display until the bottom slider bar disappears and then that last column will expand. This is frustrating having to have my Finder all across my display just to get the graphic larger.
    Is there a way to get an expander divider to show up for the last column when viewing a graphic in column view? I know I can click on the "eye" icon to see it, but the column view will expand the graphic larger than 100% so I can see more details.
    Thanks for any and all help.
    Connie

    Yes, that is how my whole finder window expands across my display until the bottom slider bar disappears....then and only then does the last column expand. I have to have open as many as 8 columns to get to my graphic. Keeping the Finder window to a smaller size and using the bottom slide bar to navigate to the far right column is nice, but all I want is that far right column where my graphic is showing to expand so I can see it better.
    Thanks but what you suggest only resizes the whole Finder window until it can expand no further, then the last column expands the graphic. But then my whole display is a huge Finder window.

  • Problem with attachtment XLS (last column of the xls)

    Hi,
    iam working on interface in which i will be sending an email along with attachtment where my email along with attachtment are working perfectly ,the problem is with the XLS where the last column of the XLS is taking 255 char which is the length of the field .
    How i have to  restrict it ?
    solution on this would be helpfull .
    Thanks ,
    shankar.
    I have attached the sample code too.
    FUNCTION zemail_send_attachment.
    ""Local Interface:
    *" IMPORTING
    *" VALUE(EMAILID)
    *" VALUE(SUBJECT)
    *" VALUE(ATYPE)
    *" TABLES
    *" ATTACH_FILE STRUCTURE SOLISTI1
    *" BODY OPTIONAL
    This table requires information about how the data in the
    tables OBJECT_HEADER, CONTENTS_BIN and CONTENTS_TXT are
    to be distributed to the documents and its attachments.
    DATA objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
    This table must contain the summarized data dependent on each object type.
    SAPscript objects store information here about forms and styles,
    for example. Excel list viewer objects store the number of rows and columns
    amongst other things and PC objects store their original file name.
    DATA objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
    This table must contain the summarized content of the objects identified as binary objects.
    DATA objbin TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
    WITH HEADER LINE.
    This table must contain the summarized content of the objects identified as ASCII objects.
    DATA objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    This table must contain the document recipients.
    DATA reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE .
    This structure must contain the attributes of the document to be sent.
    DATA: doc_ching LIKE sodocchgi1.
    DATA: tab_lines LIKE sy-tabix.
    Create the internal table for body , subject
    DATA: it_body LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    CONSTANTS: con_cret TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
    con_tab TYPE c VALUE cl_abap_char_utilities=>cr_lf.
    Move Body to Internal Table (body into it_body)
    LOOP AT body .
    MOVE body TO it_body .
    APPEND it_body .
    ENDLOOP.
    doc_ching-obj_descr = subject. "Subject of the Email
    Move the Subject and Body to OBJTXT
    objtxt[] = it_body[].
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    doc_ching-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'RAW'.
    APPEND objpack.
    Convert IT to Excel format
    IF atype = 'XLS' .
    LOOP AT attach_file .
    REPLACE ALL OCCURRENCES OF '#' IN attach_file WITH con_cret ."INTO objbin.
    IF sy-tabix = 1.
    MOVE attach_file TO objbin.
    ELSE.
    CONCATENATE con_tab attach_file INTO objbin.
    ENDIF.
    APPEND objbin.
    ENDLOOP.
    ELSEIF atype = 'TXT' .
    Convert IT to Text format
    LOOP AT attach_file .
    REPLACE ALL OCCURRENCES OF '#' IN attach_file WITH con_cret. " INTO objbin.
    CONCATENATE attach_file con_tab INTO objbin .
    APPEND objbin .
    ENDLOOP.
    ENDIF.
    DESCRIBE TABLE objbin LINES tab_lines.
    objhead = subject. APPEND objhead.
    Creating the entry for the compressed attachment
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 1.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    IF atype = 'XLS'.
    objpack-doc_type = atype.
    ELSEIF atype = 'TXT'.
    objpack-doc_type = 'RAW'.
    ENDIF.
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = 'TEST'. "Attachment File Name
    objpack-doc_size = tab_lines * 255.
    APPEND objpack..
    reclist-receiver = emailid.
    reclist-rec_type = 'U'.
    APPEND reclist.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = doc_ching
    put_in_outbox = 'X'
    commit_work = 'X'
    IMPORTING
    SENT_TO_ALL =
    NEW_OBJECT_ID =
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    receivers = reclist
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    operation_no_authorization = 4
    OTHERS = 99 .
    ENDFUNCTION.

    I had this problem after migrating to JDeveloper 10.1.3. Problem was with inconsistent DB column types. In our case, the DB column was CHAR containing only numbers, but VO defined it as NUMBER. This caused no problem in 9.0.3 we used before.
       <ViewAttribute
          Name="ParentFlagNew"
          IsPersistent="false"
          Precision="1"
          Type="oracle.jbo.domain.Number"
          ColumnType="NUMBER"
          AliasName="PARENT_FLAG_NEW"
          Expression="PARENT_FLAG_NEW"
          SQLType="NUMERIC" >
          <Properties>
             <Property Name ="DISPLAY_LIST" Value ="1=Yes,0=No" />
             <Property Name ="DISPLAY_LIST_sk" Value ="1=Áno,0=Nie" />
             <Property Name ="Renderer" Value ="sk.transacty.cm_iface.bc4j_common.ListFieldRenderer" />
          </Properties>
          <DesignTime>
             <Attr Name="_DisplaySize" Value="1" />
          </DesignTime>
       </ViewAttribute>

  • A special character in the last column in my external table

    Hello,
    I'v made a external table that looks like this :
    CREATE
    TABLE "REC_XLS"
    "FINANCE_DATE" VARCHAR2(50 BYTE),
    "CREATION_DATE" VARCHAR2(50 BYTE),
    "SENT_DATE" VARCHAR2(50 BYTE),
    "REMARKS" VARCHAR2(200 BYTE),
    "REMAINING_QUANTITY" VARCHAR2(30 BYTE),
    "CODE" VARCHAR2(30 BYTE)
    ORGANIZATION EXTERNAL
    TYPE ORACLE_LOADER DEFAULT DIRECTORY "LOADER" ACCESS PARAMETERS (
    RECORDS DELIMITED BY newline LOAD WHEN CODE!=BLANKS Skip 1 FIELDS
    TERMINATED BY 0X'09' MISSING FIELD VALUES ARE NULL REJECT ROWS
    WITH
    ALL NULL FIELDS ( Finance_date,
    creation_date, sent_date, Remarks,
    remaining_quantity, code) location ( 'Finance.tsv' )
    I exported the result in xls file and I saw in the last column a special character. The result of a copy and paste is prenseted here : "ABE
    You should notice that the last quote is in the upper line instead of at the end of ABE. This means, I think, that there is a carriage return at the end. And the 0X'09' is the tab separator. How can I get rid of this character ?

    my guess is that you run the load on unix server which uses default LF end-of-line character and the file has dos CRLF end-of-line, the easiest option is to change records delimiter in the DDL and replace "RECORDS DELIMITED BY newline" with code below
    RECORDS DELIMITED BY '\r\n'in general end-of-line can be really any character, sample above shows CRLF but it can be TAB, space, | or any other character or set of characters. I have samples of special characters on my blog http://jiri.wordpress.com/2009/01/29/oracle-external-tables-by-examples-part-1/
    hope this helps
    jiri

  • How to set the view of a table to the last column?

    Hi all,
    I have a table that allows user to add rows to it. When the number of columns exceed the number of row the viewport can display, the freshest columns are not in the view.
    My question is, how do I force the viewport to view the last rows of the table as the table grows? Instead of just showing the starting rows?

    You're mixing columns and rows in your problem description, but
    something like the following should be close
    Rectangle rect = new Rectangle( table.getWidth()-1, table.getHeight()-1, 1, 1);
    table.scrollRectToVisible( rect );: jay

  • Can i delete the Subtotal column in Cross Table?

    i create a crosstab named: hr_count, used for counting different kind of employees.
    and in 'crosstab expert', the 'column' area, i have 2 items: level_1 and level_2; the 'row' area has 1 item: department.
    my problem is, there's always a 'subtotal' column at the last column of every level 1 area, but i don't need it, i can see the 'total' number at the very last column.
    how can i delete or suppress this 'subtotal' column?
    i know i can suppress the very last 'total' column by right click mouse and choose not to show this column, but it seems i can do nothing to the 'subtotal' column. or, i must keep this 'subtotal' column in the table?

    Hi Stefanie Tan ,
    You can suppress the sub totals, Right click on your cross tba and go in Cross Tab Expart--Customize Style tab here you will find Rows: and Columns; which will have fileds.  Now click on Rows fields once you click on sub group field you can see suppress subtotal check box enables click in that check box and click on Ok.  Now check for sub totals.
    Thanks,
    Sastry

  • Select a count using the last entry of a table

    I have a huge project for which I am trying to learn some PL/SQL.
    Context:
    Entry gets put into the Orders table. What I want to do is create a trigger( out of scope for this question) that takes the last entry's product ID number and performs a count of all the PID's that match it. Then I want to compare that number with a number in the ProductTransaction table.
    I.e.
    Orders ProductTransaction
    OID TID
    PID PurchaseCount
    o_TID Price
    etc.....
    Last entry that gets put in contains
    OID PID TID
    4 100 2
    ProductTransaction
    TID PurchaseCount Price
    2 10 100.00
    What I want to do is if the last entry into the Orders table was the OID 4 then I want to count all PID=100 and determine if the PurchaseCount has been reached yet.
    The only thing I can think of is the following, but it doesn't ensure that the last PID is what we are counting:
    declare
    v_countpid number;
    begin
    select
    count(pid) into v_countpid
    from
    orders
    where OID = (select last(oid) from orders);
    dc
    Im thinking something like the above which populates the v_countpid
    and then taking another variable which is a select into which takes the last TID entered and comparing them in an if statement of some sort
    Let me know your thoughts on this....

    They you both for your replies. I was pushing myself to stay up late last night and I guess I didn't included everything.
    Here it goes.
    The concept is to have someone buy a product lets say at 10 dollars and it will take 10 other people for you to finally get your product released to you.
    So when I purhcase PRODUCT A and put the entry into the orders table it will be something like this:
    OID = 1
    PID = 101
    TID = 2
    TIMEOFPURCHASE=<timestamp>
    etc........
    Now once that is entered into the table I am going to have a trigger as an after insert that will count the total PID's in the table that match what I just put into it, as in this case it was PID=101. The count of PID=101 will then be matched against the ProductTransaction PurchaseCount field to determine if that product should be released to the person with the lowest timestamp.
    So....
    ProductTransaction
    TID=2
    PRICE=$10
    PurchaseCount=10
    ORDERS
    OID PID TID TOP
    1 101 2 3 am
    2 101 2 5 am
    3 30 1 12 pm
    4 101 2 4 pm
    Example. The last entry was OID=4 so it will count up the number of PID=101 and then that number is compared against ProductTransaction purchase count. If hasn't exceeded then nothing happens. If the number is matched then OID=1 is moved into the shipping table for processing.
    Let me know if this still doesn't clarify, or if there is a better way to do this....

  • Table where the last name and the first anme are stored

    Hi ALL,
    I would like to know the table in which the last name and the first name of the employee gets stored?

    Hi,
    You can use the table PA0002 for first and last name of the employee.
    Please refer the below fields in table PA0002
    First name- PA0002<VORNA>
    Last Name-PA0002<NACHN>
    Second Name-PA0002<NACH2>
    Regards
    Raviiiiiiiiiii

  • Unpivot taking the last letter from the column name

    Hi guys, having
    DATE               Period1 Period2 Period3 Period4
    01/01/2014       1.02       1.06      1.02      1.03
    02/01/2014       1.06       1.05      1.04      1.06
    I would like an unptivot as
    01/01/2014    1        1.02
    01/01/2014    2        1.06
    01/01/2014    3        1.02
    01/01/2014    4        1.03
    02/01/2014    1        1.06
    02/01/2014    2        1.05
    02/01/2014    3        1.04
    02/01/2014    4        1.06
    But I'm wondering how can I take the last letter of the column. Maybe I should use a select case...
    Any advices? Thank you   

    DECLARE @Table TABLE
    dt DATE,
    P1 INT NULL,
    P2 INT NULL,
    P3 INT NULL,
    P4 INt NULL
    INSERT INTO @Table(dt, P1, P2, P3, P4)
    VALUES('20140101',10,null,20,3);
    INSERT INTO @Table(dt, P1, P2, P3, P4)
    VALUES('20140102',50,25,15,5);
    SELECT dt, row_number() over (partition by dt order by dt) rn,per AS DayMax FROM @Table
    UNPIVOT (per FOR DayNumber IN (P1, P2, P3, P4)) AS c
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Is there a way to make the last column in finder auto expand?

    I know that you can double click the double bar at the bottom right . . . but can't the finder be set to auto expand on the last column so i don't have to click that thing every time i wish to see the long named files ?
    Perhaps i should just use Bridge but it seems so slow and cumbersome compared to Finder.
    thanks for any advice.
    PS . . . is this available on the newest OS . . . going to upgrade one of these days.

    No, the finder's column view does not have auto resizing columns.
    It does have auto condensing of file names for the narrow display.
    Which is what you are trying to overcome.
    To accomplish your task, switch to list view.
    Select your file. Then switch back to column view.
    The trick is to learn your FINDER command key short cuts.
    command 1 = icon view
    command 2 = list view
    command 3 = column view.
    So you would press [command] and [3] to view the columns.
    Navigate about until you get a column of unhelpfully condensed names.
    Switch to list view by pressing [command] and [2]
    Select the file from the fully displayed names list.
    At this point you can press [command] [down arrow] OR [command] [o] to enter/open the selected item;
    or Switch back to column view by pressing [command] and [3] then continue browsing deeper.

  • The Last Column in LOGIC 8 is partly cut off.

    I know this sounds dumb, but the last column in my LOGIC 8 is cut off. This is the column which contains the folders and sounds of instruments, loops etc. It was there when I first started using it a few months ago but for some reason it just reduced to half it's size and and I cant see the other half. Tried to 'drag it open' but that dont work. Can anyone help !!!!!!!!!!!!!

    Futz with it man. Is the arrange window too wide and off your screen? Open another arrange window, turn the lists view on/off. Drag the dividing line back and forth. Just futz around with it, it's most likely pilot error...

Maybe you are looking for

  • How do I create more tabs in my tab control, and place graphs/charts on these.

    It has to be done in the program depending on a setup file. This is due to that I have from 2 till 100 graphs/charts needed to be shown. One graph/chart on each tab. How many tabs I need comes from the setup file.

  • How do I shrink the gray desktop area back to normal

    I am working on a 40 page magazine and suddenly after one of the spread the gray desktop is 10 inches long instead of 2 so I have to scroll really far to get to the next spread. Anyone know what I did accidentally and how to change it back, really an

  • How to turn logo background transparent?

    I need to change the logo background transparent so this logo integrates seamlessly on my website instead of looking like a big black box with a logo in it. Is it possible to remove the black background from every where except behind the lettering? H

  • Draw a smooth shape out of point array where points are in arbitrary order

    hi folks, I got a little problem I just can't get figured out: - there's an array of points (x,y) - the points inside this array are arbitrary - now I need to find out which points define the outermost shape - all other points that are inside this ou

  • Is it SystemUIServer, or is it not SystemUIServer?

    I've heard of many problems people are having with this, but I can't seem to find any that are quite the same as mine, so I was hoping someone could shed some light on it. After an indeterminate amount of time, the computer locks up completely and in