VBA code to update Excel Data in sharePoint list

hi Team,
I have excel sheet created having data. I need to upload it in sharepoint List.
Please provide me VBA code for the same.

Please try this.
Sub UpdateSpecificCells()
'If nobody has the file checked out
If Workbooks.CanCheckOut("http://excel-pc:43231/Shared Documents/ExcelList.xlsb") = True Then
Application.DisplayAlerts = False
'Open the file on the SharePoint server
Workbooks.Open Filename:="http://excel-pc:43231/Shared Documents/ExcelList.xlsb", UpdateLinks:=xlUpdateLinksNever
ActiveSheet.Cells(2, 7).Value = 100
ActiveSheet.Cells(3, 7).Value = 200
ActiveSheet.Cells(4, 7).Value = 300
'Close the workbook
Workbooks("ExcelList.xlsb").Save
Workbooks("ExcelList.xlsb").Close
End If
End Sub
I haven't used SharePoint in many years, and I can't test that code now, but I've used that before to update Excel files in SharePoint.
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

Similar Messages

  • Upload Excel data to Sharepoint list VIA infopath form

    Hi,
    I'll try to explain the process of what I want to do first.
    1. In Excel
    I have an exceldocument (XLS, XLSX or XLSM) with 4 named columns and a named worksheet saved locally on my computer.
    I want to upload this data into preferably a custom list in sharepoint but it needs to run via a infopath template first.
    2. In Infopath
    The Infopath template will prompt the user to specify values in 2 additional fields.
    After giving input to these fields user may browse for the locally stored excel document and upload the document.
    In the same infopath template a dynamic array should be visible containing 6 columns (4 from excel + 2 from headerlevel of template) and the amount of rows based on the number of rows from excelsheet.
    At the end of template a submit button is found for uploading the entire array into sharepoint custom list.
    Is this possible to do at all?
    NOTE! End user should not have to save the excelsheet as XML file nor do a XML mapping.
    Infopath should, perhaps with help of VBA read excelsheet and transfer data to correct destination in sharepoint on it self.
    Looking forward to your reply

    Hi Jonas,
    You can attach your Excel doucment into InfoPath form and send InfoPath form to a custom web service. Then you can parse the Excel data and combine the Excel data and additional fields into SharePoint list in the customized  web service.
    For more information, you can have a look at the thread:
    http://dandeng.blogspot.com/2012/03/submit-infopath-form-data-to-web.html
    http://www.codeproject.com/Articles/88547/Submit-entire-InfoPath-form-to-web-service
    https://social.msdn.microsoft.com/Forums/office/en-US/590f1e78-5c08-47bd-8af4-9709102b568d/webservice-to-send-attachments-in-infopath-form-to-different-location?forum=sharepointcustomization
    https://msdn.microsoft.com/en-us/library/office/gg575571.aspx?f=255&MSPPError=-2147217396
    Best Regards,
    Eric
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • On excel sheet upload read the workbook and populate data to sharepoint list

    Requirement in my current project:
    In a document library when I upload an excel sheet, a specific workbook has to be read and the contents have to be uploaded to a sharepoint custom list.
    The approach followed was create an event receiver and register as a feature. Following is the code for event receiver.
    public override void ItemAdded(SPItemEventProperties properties)
                base.ItemAdded(properties);
                var list = getSPList("{150301BF-D0BD-452C-90D7-2D6CD082A247}");          
                SPListItem doc = properties.ListItem;
                doc["Msg"] = "items deleted from req list";
                doc.Update();
                string excelname=doc.File.Name;
                System.Diagnostics.EventLog.WriteEntry("ExcelUpload", "calling read excel");
                string filepath = doc.File.Url.ToString();
                doc["Msg"] = "excel name" + excelname + filepath;
                doc.Update();
                readExcel(excelname,filepath);
            private static SPList getSPList(String SPListGuid)
               // SPSite Site = SPContext.Current.Site;
                SPSite Site = new SPSite("http://omistestsrv:32252/sites/OMD");
                SPWeb web = Site.OpenWeb();
                Guid listid = new Guid(SPListGuid);
                web.AllowUnsafeUpdates = true;
                SPList List = web.Lists[listid];
                return List;
            private void readExcel(string excelname,string filepath)
                try
                    SPSecurity.RunWithElevatedPrivileges(delegate()
                        using (SPSite Site = new SPSite("http://omistestsrv:32252/sites/OMD"))
                            SPWeb web = Site.OpenWeb();
                            string workbookpath = web.Url + "/" + filepath;
                            web.AllowUnsafeUpdates = true;
                            var _excelApp = new Microsoft.Office.Interop.Excel.Application();
                            System.Diagnostics.EventLog.WriteEntry("ExcelUpload", "iside read excel");
        //my code breaks or fails when cursor reaches this statement. I am not able to open the excel sheet, there is no    //problem related to the permission. same code snippet works in a console application. but when tried as an
    event    //handler in sharepoint it breaks. can anyone help me to resolve the problem
                            workBook = _excelApp.Workbooks.Open(workbookpath, Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing,
    Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing);
                            System.Diagnostics.EventLog.WriteEntry("ExcelUpload", "after excel open");
                                int numSheets = workBook.Sheets.Count;
                                // Iterate through the sheets. They are indexed starting at 1.
                                System.Diagnostics.EventLog.WriteEntry("ExcelUpload", numSheets.ToString());
                                for (int sheetNum = 12; sheetNum < 13; sheetNum++)
                                    System.Diagnostics.EventLog.WriteEntry("ExcelUpload", "inside first for
    loop");
                                    Worksheet sheet = (Microsoft.Office.Interop.Excel.Worksheet)workBook.Sheets[sheetNum];
                                    Microsoft.Office.Interop.Excel.Range excelRange = sheet.get_Range("A13",
    "P89") as Microsoft.Office.Interop.Excel.Range;
                                    object[,] valueArray = (object[,])excelRange.get_Value(
                                        Microsoft.Office.Interop.Excel.XlRangeValueDataType.xlRangeValueDefault);
                                    var list = getSPList("{150301BF-D0BD-452C-90D7-2D6CD082A247}");
                                    for (int L = 1; L <= excelRange.Rows.Count; L++)
                                        string stringVal = valueArray[L, 1] as string;
                                        if ((valueArray[L, 1] != null) && (!string.IsNullOrEmpty(stringVal)))
                                            System.Diagnostics.EventLog.WriteEntry("ExcelUpload",
    "inside second for loop");
                                            SPListItemCollection
    listItems = list.Items;
                                            SPListItem item = listItems.Add();
                                            item["Product"] = valueArray[L,
    1];
                                            item["App"] = valueArray[L,
    2];
                                            web.AllowUnsafeUpdates
    = true;
                                            item.Update();
                                web.AllowUnsafeUpdates = false;
                                //Or Another Method with valueArray Object like "ProcessObjects(valueArray);"
                                _excelApp.Workbooks.Close();
                    //workBook.Close(false, excelname, null);
                    //Marshal.ReleaseComObject(workBook);
                catch (Exception e)
                    System.Diagnostics.EventLog.WriteEntry("ExcelUpload", e.Message.ToString());
                finally
                    System.Diagnostics.EventLog.WriteEntry("ExcelUpload", "finally block");
    Is this the only approach to meet this requirement or is there any other way to crack it. sharepoint techies please help me.

    as you described the scenario of the event that it should happen when user upload excel to a document library. Event Receiver is your best bet. However if you would have a requirement that users can send excel files any time to a network file location and
    you want to pick it, read it and create list items etc. You would write a sharepoint timer job that would run every 10 minute to check for file and if available on the network drive, perform the operation etc. so that users who send excel file does not need
    to come to the sharepoint etc. You can see that you have Event Receivcer option or Timer job option OR you would write a console application to trigger the code at a scheduled time on sharepoint server etc. so you are using the event receiver in the correct
    scenario.
    Moonis Tahir MVP, MCPD, MCSD.net, MCTS BizTalk 2006/SQL 2005/SharePoint Server 2007 (Dev & Config)

  • Excel Services with SharePoint List Data in SharePoint 2013 - Chart is not refreshing automatically

    Hi Everyone,
    This is My req: I m going to display pie chart and Bar chart in share point 2013.
    Steps I have follwed:
    1. Export the list to excel.
    2.Using the Power Pivot table I have done the chart.
    3. Uploaded into document Library.
    4. Added into the web part. 
    Chart are displaying. But When ever user added the data into the list chart is refreshing.
    Is there any option to refresh the data in chart? Waiting for valuable replies.
    Regards, Manoj Prabakar

    SharePoint lists as data sources in Excel Services is not supported.That's the reason refreshing is not working. There are some work around you can use  -
    Export as Data Feed - Export your SharePoint list as Data Feed , use this data feed to a PowerPivot for Excel workbook and publish this PowerPivot using Excel Services.
    User-defined functions  - write UDF in C# and extend the Excel Services functionality to work with SharePoint lists.
    https://msdn.microsoft.com/library/bb267252(office.12).aspx#Office2007ExcelServicesUnlimited_SharePointLists
    Web Services API -
    The Web Services API can be used to push data from a database and then refresh the data in a SharePoint Server list by using Excel Services.
    JavaScript Object Model - The JavaScript Object Model for Excel Services in Microsoft SharePoint Server 2010 provides many solutions for Excel Services.
    More details  - 
    https://technet.microsoft.com/en-us/library/gg576960.aspx
    Thanks
    Ganesh Jat [My Blog |
    LinkedIn | Twitter ]
    Please click 'Mark As Answer' if a post solves your problem or 'Vote As Helpful' if it was useful.

  • Append excel sheet data to sharepoint list

    HI,
    I have an excel sheet and i have publshed this list on sharepoint 2010.
    Now i want to append some more records to the same list on sharepoint.
    So is it possible in sharepoint?
    Please help to solve the issue.
    Thanks & Regards
    Rajni

    Hi,
    I think there is no other method to update an existing list with Excel. It is only possible to create a new list based on an Excel-Sheet.
    To save an Excel sheet to a list, click Site Actions->More options->Import Spreadsheet.
    Browse for an appropriate file to import. The file will be imported as a list.
    Thanks.
    Tracy Cai
    TechNet Community Support

  • Receiving error while updating a folder inside sharepoint list

    What my code does - runs through each folders present in a list, and if any of the folders are in the name with current year, then it shall be renamed, ie 2012 to 2012_Backup. Soon after it is renamed we will create a name folder named 2012 and I get error
    here. Below is my code. Please suggest a work arround please.
    for (int i = 0; i < additionalList.Folders.Count; i++)
                        if (additionalList.Folders[i].Folder.Name == Convert.ToString(DateTime.Now.Year))
                            oldFolder = targetList_additionalList.Folders[i];
                            oldFolder[Title] = Convert.ToString(DateTime.Now.Year) + backUp;
                            oldFolder.Update();
                            additionalList.Update();
    SPListItem newfolder = targetList_additionalList.AddItem(workflowProperties.Item.Folder.ServerRelativeUrl, SPFileSystemObjectType.File);
                              newfolder[Title] = Convert.ToString(DateTime.Now.Year);
                       newfolder.Update();
                       targetList_additionalList.Update();
    Error Details :
    Microsoft.SharePoint.SPException: Invalid file name.
    The file name you specified could not be used.  It may be the name of an existing file or directory, or you may not have permission to access the file.
    Shameej

    Hi shameej,
    Based on the error message, the issue should be caused that the new folder is created before the old folder name change.
    From your code sample, you seems to execute the code in workflow, if so, before the new folder item is created, add wait for sometime action, whether this can fix the issue?
    if it isn't the issue, would you please help to provide more information about your code execution environment, in which type of project?
    Thanks,
    Qiao Wei
    TechNet Community Support

  • How to show data from sharepoint list in mm dd yyyy format using Server Object Model

    In SharePoint 2010
    List "Employee", Colum Name "JoinDate" 
    has stored data in  (01/31/2014 12.00 PM) mm\dd\yyyy hr:mm PM format.
    How to display this data in mm\dd\yyyy only using C# on custom web part?

    //Write the code to read your list item
    SPListItem item = list.Items[0];
    //Get a DateTime object with the list column value
    DateTime date = Convert.ToDateTime(item["Date Column Name"]);
    String strDate = date.ToString("mm-dd-yyyy hh:mm tt");
    //you can also try ("dd/mmm/yyyy")
    http://sharepoint.stackexchange.com/questions/12820/safest-way-to-get-a-date-from-sharepoint-into-a-c-datetime-field-using-object

  • SSRS and data from SharePoint lists - special characters in HTML

    Hi All,
    This may not actually fit into this forum, but here goes anyway...
    We're using SSRS to report on data stored in Project Server workspaces (so SharePoint lists). Prior to upgrading to 2013, we could pull this data in and set the "Placeholder properties" of the text box to interpret HTML tags as styles and it would
    format everything as it appeared in the SharePoint list. Now that we have upgraded to 2013, this works with a few notable exceptions - some special characters are rendered as their escaped/encoded (whatever the term is) - so a colon which is within the text
    field in SharePoint, rather than appearing in the SSRS report as ":" appears as "&#58;".
    These are multiline, rich text formatted columns in the SharePoint list. Using =Replace(Fields!Description.Value,"&#58;",":") in the report makes the appropriate replacement, but given that this occurs with a handful of other special
    characters as well, this solution becomes very unruley very quickly. Has anyone else encountered this, or does anyone have any other suggestions for a work around?
    If not now, when?

    Facing same issue but having no solution, please suggest..

  • How to read data from SharePoint list and append to html table?

    Hi All,
    I would like to create custom view of SharePoint list, so want to append those sharepoint list  items in a custom html table design using content editor webpart.
    How to achieve this? thanks in advance!

    Content edit web part is not the right control. You can either Content Query Web Part
    or Data view web part, where you need to modify xslt template using
    SharePoint Designer and can render list data as per choice.
    For Content Query Web Part:
    Using the Content Query Web Part
    Customizing the Content Query Web Part and Item Style
    How to Customize SharePoint List Content Display using Content Query Web Part
    For Data View Web Parts
    Working with Data view Web Parts
    Adnan Amin MCT, SharePoint Architect | If you find this post useful kindly please mark it as an answer.

  • Cannot update due date in SharePoint 2010 Approvel Workflow generated Task

    Wondering why due date cannot be changed by users with List permissions on a Task which was generated from the built-in Approval workflow.
    I can have the workflow set the initial due date. The business process dictates that at times the due date need to be updated on the Task before they are completed (shift to the right or whatever).
    The column settings for the due date field do not seem to be set as read only??? why can the not be updated by users/admins?
    If the due date must be updated by a workflow how can a workflow be manually be run...like an administrator business process feature?
    BTW...this project mandates that all processes are run with OOB settings (codeless).
    Thanks
    Ok, found the answer to this on another post: click on the workflow status field of the workflow that generated the tasks. Then click "Add or update assignees". Very nice!

    Hi,
    Thank you for sharing this with us!
    Beside the way you mentioned, you can also try to reassign the task from the task list directly. Thus you can enter a new duration for this task and SharePoint will generate a new task.
    Thanks
    Pengyu Zhao
    TechNet Community Support

  • Pulling user/group field data from SharePoint list using REST, jQuery, Knockout.js Sharepoint 2013

    I'm trying to make an interactive task board based on the task list app in SharePoint 2013. The task lisk includes fields like "Title","Description","Status","% Complete","Due Date","Assigned To",
    etc. I used knockout.js to bind "Title","Description", and "Status" to my HTML controls. Here is some of the code:
    var ViewModal = function(items, listname){
    var self = this;
    self.sortBy = ko.observableArray(sortBy);
    self.tasks = ko.observableArray(items);
    self.listname = ko.observable(listname);
    self.auto = ko.observable(false);
    self.getTasks = function() {
    clearTimeout(self.getTasks);
    // server relative url to REST service endpoint
    var ajaxurl = _spPageContextInfo.webServerRelativeUrl + "/_vti_bin/listdata.svc/" + self.listname() + "?$orderby=PriorityValue";
    $.ajax({
    type: "GET",
    url: ajaxurl,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    cache: false,
    processData: true,
    success: function (data, status, xhr) {
    if (status == "success" && data) {
    ko.mapping.fromJS(data.d.results, mapping, self.tasks)
    $(".task-item").draggable();
    error: alert
    if (self.auto()) {
    setTimeout(self.getTasks, 10000);
    <div class="tasks-column">
    <div class="column-header">Not Started</div>
    <!-- ko foreach: tasksNotStarted -->
    <div class="task-item">
    <div class="view" data-bind="visible: !IsEditing()">
    <button class="edit" data-bind="click: $root.editTask">edit</button>
    <h2><span data-bind="text: Title"></span></h2>
    <div data-bind="html: Description"></div>
    <span data-bind="text: PriorityValue"></span>
    </div>
    <div class="edit" data-bind="visible: IsEditing">
    <button class="save" data-bind="click: $root.saveTask">save</button>
    <input type="text" data-bind="value: Title"></input>
    </div>
    </div>
    I'm having trouble displaying the data from the "Assigned To" user/group field. I tried:
    <span data-bind="text: AssignedTo"></span>
    But it displays the field as [object Object]
    I tried using $select/$expand
    ?$select=Title,AssignedTo/Id,Assignedto/Title&$expand=AssignedTo/Id,AssignedTo/T‌​itle";
    But it still returns the [object Object]

    Hi,
    Please use the REST URI below:
    /_api/lists/getbytitle('ListName')/items?$select=Title,AssignedTo/ID,AssignedTo/Title&$expand=AssignedTo/ID,AssignedTo/Title
    More information for your reference:
    How to get User Details and User Group Details in SharePoint 2013 REST API with Knockout for SharePoint Js (KoSpJs)
    http://www.ashokraja.me/post/How-to-get-User-Details-and-User-Group-Details-in-SharePoint-2013-REST-API-with-Knockout-for-SharePoint-Js-(KoSpJs).aspx
    How to Get Login Name and Display Name using SharePoint 2013 REST API
    https://www.nothingbutsharepoint.com/sites/devwiki/articles/pages/how-to-get-login-name-and-display-name-using-sharepoint-2013-rest-api.aspx
    Best Regards
    Dennis Guo
    TechNet Community Support

  • PowerShell code not working import XML to SharePoint list

     
    All hi, I don't understand why doesn't work? XML file from here -
    http://www.cbr.ru/scripts/XML_daily.asp?date_req=23/01/2015
    if(!(Get-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction:SilentlyContinue))
    Add-PSSnapin Microsoft.SharePoint.Powershell
    #Set these two variables accordingly
    $WebURL = “http://sharepoint/Test”
    $ListName = "Test"
    $XMLFilePath = "C:\Test\XML\XML_daily_asp.xml"
    #Get the Web
    $web = Get-SPWeb $WebURL
    #Get the List
    $ProjectList = $web.Lists[$ListName]
    #import xml file
    $ProjectXmlFile = Get-Content $XMLFilePath
    foreach ($XMLProject in $ProjectXmlFile)
    $NewProject = $ProjectList.Items.Add()
    $NewProject["Title"] = $XMLProject.Value
    $NewProject["NumCode"] = $XMLProject.NumCode
    $NewProject["CharCode"] = $XMLProject.CharCode
    $NewProject["Nominal"] = $XMLProject.Nominal
    $NewProject["Name"] = $XMLProject.Name
    $NewProject["Value"] = $XMLProject.Value
    $NewProject.Update()
    Write-Host "Has been Added to External Projects list!"

    I understood, my error was that it is necessary to add (.ValCurs.Valute) to $ProjectXmlFile.ValCurs.Valute, and also surely to specify an ID (i.e. Valute ID)
    This' working code:
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
    $WebURL = "http://sharepoint/Test"
    $ListName = "Test"
    $XMLFilePath = "C:\Test\XML_daily_asp.xml"
    $web = Get-SPWeb $WebURL
    #Get the List
    $ProjectList = $web.Lists[$ListName]
    #import xml file
    [xml]$ProjectXmlFile = Get-Content $XMLFilePath
    foreach ($XMLProject in $ProjectXmlFile.ValCurs.Valute)
    $NewProject = $ProjectList.Items.Add()
    $NewProject["Title"] = $XMLProject.id
    $NewProject["NumCode"] = $XMLProject.NumCode
    #Set the People Picker Field
    $NewProject["CharCode"] = $XMLProject.CharCode
    $NewProject["Nominal"] = $XMLProject.Nominal
    $NewProject["Name"] = $XMLProject.Name
    $NewProject["Value"] = $XMLProject.Value
    $NewProject.Update()
    Write-Host "Project $($XMLProject.id) has been Added to External Projects list!"

  • Error while reading data from SharePoint List - using object model

    Any idea what could be reason for this error:-
    Microsoft.SharePoint.Library.SPRequestInternalClass.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback,
    ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView)
       at Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback,
    ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView)
       at Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData()
       at Microsoft.SharePoint.SPListItemCollection.GetDataTableCore(Boolean isJsGrid)
       at HRCompetencyGuide.SPHelper.<>c__DisplayClass2.<getDataTableFromList>b__0()
       at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2()
       at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
       at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)
       at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode
    Mark ANSWER if this reply resolves your query, If helpful then VOTE HELPFUL
    INSQLSERVER.COM
    Mohammad Nizamuddin

    It is a simple code:- below is the part of the code taken from the method
    SPSecurity.RunWithElevatedPrivileges(delegate()
    using (SPSite site = new SPSite(siteURL))
    if (site != null)
    using (SPWeb web = site.OpenWeb())
    SPList list = web.Lists.TryGetList(listName);
    if (whereQuery == null)
    collection = list.GetItems().GetDataTable();
    else
    collection = list.GetItems(whereQuery).GetDataTable();
    Mark ANSWER if this reply resolves your query, If helpful then VOTE HELPFUL
    INSQLSERVER.COM
    Mohammad Nizamuddin

  • How to copy Excel sheet data to SharePoint 2010 List?

    Hi,
       I need to export excel data to SharePoint 2010 list. I have created 22 columns in list which are of following Column types:
    Single line of text,
    Multiple line of text,
    Choice
    Number,
    Date,
    Person or Group.
    Now i need to export the excel data to SharePoint list.
    When iam trying to copy data from excel to List , it is showing as "The selected cells are read only".
    can someone guide on this to export spread sheet data to SharePoint list without importing Spreadsheet.
    Thanks in advance.
    Badri

    I've updated the example of using PowerShell to include a Person field (user field) and a choice field.
    The CSV file has the following columns:
    TRIP_NO
    VESSEL_NAME
    FLAG
    AGENT_NAME
    CURRENT_LOCATION
    RPT_DATE
    EMPLOYEE
    EMPLOYEE_TYPE
    #Get the CSV file and connect to the SharePoint list
    $vessellist = import-csv -Path C:\Temp\VesselInPortReport.csv
    $l = (Get-Spweb "http://devmy101").GetList("http://devmy101/Lists/smarInPort")
    #Get the lists EmployeeType field (choice)
    $employeeType = $l.Fields["EmployeeType"] -as [Microsoft.SharePoint.SPFieldChoice]
    #Loop through the items and add them to the list
    $r = 1;
    foreach($item in $vessellist)
    $ni = $l.items.Add();
    #Add the Title, using the rows VESSEL_NAME column
    $ni["Title"] = $item.VESSEL_NAME;
    #Add the "Date Recorded" field, using the csv rows "RPT_DATE" column
    [DateTime]$rd = New-Object System.DateTime;
    if([DateTime]::TryParse($item.RPT_DATE, [ref]$rd)){
    $ni["Date Recorded"] = $rd;
    #Add the csv rows "TRIP_NO" column to the new list items "Trip Id" field (SPFieldNumber)
    [Int64]$tn = New-Object System.Int64;
    if([Int64]::TryParse($item.TRIP_NO, [ref] $tn)){
    $ni["Trip Id"] = $tn;
    #Add some other text properties
    $ni["Flag"] = $item.FLAG;
    $ni["Agent Name"] = $item.AGENT_NAME;
    $ni["Current Location"] = $item.CURRENT_LOCATION;
    #Add user information
    $ni["employee"] = $w.EnsureUser($item.EMPLOYEE); #In this case, the $item.EMPLOYEE value from the spreadsheet is a persons name. Eg. "Matthew Yarlett"
    $employeeType.ParseAndSetValue($ni,$item.EMPLOYEE_TYPE); #In this case, the $item.EMPLOYEE_TYPE value from the spreadsheet is valid choice present in the EmployeeType list field. Eg. "Manager"
    #Update the item
    $ni.Update()
    Write-Host ([String]::Format("Added record:{0}",$r));
    $r++;
    Regards, Matthew
    MCPD | MCITP
    My Blog
    Please remember to click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if it was useful.
    I just added a webpart to the TechNet Gallery that allows administrative users to upload, crop and format user profile photos. Check it out here:
    Upload and Crop User Profile Photos

  • Automatically importing a csv file to a SharePoint list

    I get a csv file from a program every day. Instead of copying and pasting the data into a SP list, is it possible to have the file copied to a location and SP import it on a regular basis? I would avoid the manual copy paste as well as I wouldn't have
    to be present to do the conversion.

    Hi
    Here is the powershell script which you can use
    function Add-CsvDataToList([Microsoft.SharePoint.SPWeb]$web, [string] $listName, [string] $csvPath) {
    $list = $web.Lists.get_Item($listName)
    Import-Csv $csvPath | ForEach-Object {
    $csvRow = $_
    $newItem = $list.Items.Add()
    Get-Member -InputObject $csvRow -MemberType NoteProperty | ForEach-Object {
    $property = $_.Name
    $newItem.set_Item($property, $csvRow.$property) } $newItem.Update()
    Following are the links for reference
    http://blog.brianfarnhill.com/2012/07/populate-a-sharepoint-list-with-items-in-a-csv-file-using-powershell
    http://blogs.technet.com/b/stuffstevesays/archive/2013/06/07/populating-a-sharepoint-list-using-powershell.aspx
    https://ravendra.wordpress.com/uploading-csv-excel-data-into-sharepoint-list/
    Please 'propose as answer'
    if it helped you, also 'vote helpful' if you like this
    reply.
    Amit Kotha

Maybe you are looking for

  • Displaying only one value for a key figure

    Hi guys, I am building a query in BEx Analyzer (v 3.5) where I am facing a difficult requirement. In the cube I have the following structure: Bank Account | Date | (.....) | KF: Amount | KF:Closing Balance A                   | 29.10.2008  | 300     

  • First Dep Run - Account requires an assignment to a CO object

    Hi, We did a legacy data transfer for this november, for a whole company code Fixed assets. We run the initial load in our testing environment and now we are trying to run the first month depreciation (Nov09) When we run Nov an error message is displ

  • Multiple files in FS - Logging using Bus Service with file transport

    I created a business service based on FS. I called this BS from proxy service by adding routing step. This is a simple test. But I am not sure why I am seeing 4 files in my file system when I ran the logging proxy service.

  • I can't sign into meebo using firefox

    i'm using meebo through justin.tv i can't sign in i only have the problem signing in on firefox here is a video of it http://www.youtube.com/watch?v=b3jeQN5lwuc

  • GWIA - "Will Not Relay" Message

    I have a GroupWise mail system set up with two mail servers: 1 Windows Server 2003 SP1 - GFI MailEssentials, GFI MailSecurity, and GroupWise WebAccess front-end. 1 Netware 6.5SP6 - GroupWise 7.1 GWIA, POA, MTA, and WebAcc / Document Agents. The way o