none
Opening .CSV files for 'Direct editing' via Excel

    Question

  • I've been asked to configure Sharepoint 2010 to allow users to direct edit .csv files from sharepoint by opening the files in MS Excel. I've altered the MIME type on IIS to point to Excel hoping this would do it but it still doesn't allow direct editing of the file. It works fine for .XLS files. Is it possible to do this and if so how?
    Thursday, January 26, 2012 3:52 PM

Answers

  • That is right, but you have to distinguish two different things,

    when clicking on the link you ask iis to deliver the content, hence the correct mime type has to set,

    when you associate the client program this will be opened and the output stream from iis goes to it.

    If you use the ECB and click  on "Edit in Excel" or whatever is put there, that is a different story,

    in this case a function in ows.js named OpenDocument is called, the script determines if the office client

    application is installed and based on that takes action. The Problem here is that there is no default for

    .csv (no mapping to the progID of Excel), so the script asks you if you want to open it and afterwards complains,

    that there is no matching client application installed. So you can change ows.js (not recommended), or create

    a custom OpenDocument behaviour (complicated). There are some Articles regarding this, this one

    is somewhat older but explains it quite well: http://msdn.microsoft.com/en-us/library/ie/dd588661(v=office.11).aspx

    Markus Feldmann, mind-it ug


    if it helps you, please mark as answer.
    • Marked as answer by Wayne Fan Tuesday, February 7, 2012 1:57 AM
    Friday, January 27, 2012 4:25 PM

All replies

  • Hi Nick,

     

    I fiddled around with this a bit, I guess it can be put into the ECB menu, but not the easy way.

    If you put a line like this:

     <Mapping Key="csv" Value="csv16.gif" EditText="CSV in Microsoft Excel" OpenControl="SharePoint.OpenDocuments" />

    into Docicon.xml it won´t work, since OpenDocument does not figure out correctly how to deal with it, so I tried to do it by using javascript, which I

    put into a Content Editor Webpart:

     

    <script language="javascript" type="text/javascript">

    function EditDocWithProgID()
    {
        EditDocumentButton = new ActiveXObject("SharePoint.OpenDocuments.3");

        if (EditDocumentButton)
        {
            //var strDocument = document.frmEditDoc.EditFile.value;
            //var varProgID = document.frmEditDoc.FileProgID.value;

            EditDocumentButton.EditDocument("http://wsf2010.toolworks.local/Freigegebene%20Dokumente/TEST.csv", "Excel.Sheet");
       }
    }
    </script>

    <div class="commentWrapper">
    <div class="title">The Button</div>
    <div><input id="submit" type="button" value="doit" onclick="EditDocWithProgID();" /></div>
    </div>

    If I now push the button Excel starts opening the referenced .csv File, so to integrate it nicely

    you can create a Feature that extends the ECB Menu and put something like <UrlAction Url="javascript:..."/>  into

    the Elements File, then you schould be able to open the csv File in Question by using the ECB Menu.

    I hope it helps, if you need assistence with the Feature, let me know, though it will be tomorrow evening when I´ll be able to look into it,...

    Markus Feldmann

     

    if it helps you, please mark as answer


    if it helps you, please mark as answer.
    Thursday, January 26, 2012 6:49 PM
  • Thanks for your response. I'll have to see if I have enough time in work tomorrow to take a look at what you have suggested in full. I'm fairly new to Sharepoint and wondered if it was purely some sort of configuration setting that needed to be switched on. I have just scanned your answer tonight and it looks like Sharepoint has to be hacked to get it do what I want. I have to be careful as if I end up doing something that causes the site to go down I'll have important people knocking on my door.

    Thursday, January 26, 2012 11:45 PM
  • Nah,

     

    thats not so dangerous, what I basically suggested is to create a ECB shortcut (That is the context Menu of a file in a list view), that triggers some javascript, what then triggers the client application to start.

    Depending on the user rights you have in the UI there should not be too much potential to do harm with this script, since it just calls this "Start the right client code from ows.js". But you can of course always get in touch with the "knowing" people in your organization to assist you,... what by the way is always a good idea.

     

    regards,

     

    Markus Feldmann


    if it helps you, please mark as answer.
    Friday, January 27, 2012 2:40 PM
  • Have you tried setting Excel as the default access program for .CSV files?

    1. Go to Start > Run > type 'Control Default Programs'.
    2. This opens the control panel at the Default Programs screen.  Select "Associate A File Type or Protocol With A System".
    3. After it scans your system, look for, and select, the ".csv" under the Name column.
    4. Click "Change Program", select Excel, and voila!

    I had this issue and that is what worked for me - it kept opening them in Notepad.  I have the ability to open CSV files in Excel on a SharePoint page,  however this is the only thing I have ever configured other than MIME types, so this may be what you're looking for.

    If it's not, you have my sincerest apologies.

     

    Friday, January 27, 2012 3:49 PM
  • That is right, but you have to distinguish two different things,

    when clicking on the link you ask iis to deliver the content, hence the correct mime type has to set,

    when you associate the client program this will be opened and the output stream from iis goes to it.

    If you use the ECB and click  on "Edit in Excel" or whatever is put there, that is a different story,

    in this case a function in ows.js named OpenDocument is called, the script determines if the office client

    application is installed and based on that takes action. The Problem here is that there is no default for

    .csv (no mapping to the progID of Excel), so the script asks you if you want to open it and afterwards complains,

    that there is no matching client application installed. So you can change ows.js (not recommended), or create

    a custom OpenDocument behaviour (complicated). There are some Articles regarding this, this one

    is somewhat older but explains it quite well: http://msdn.microsoft.com/en-us/library/ie/dd588661(v=office.11).aspx

    Markus Feldmann, mind-it ug


    if it helps you, please mark as answer.
    • Marked as answer by Wayne Fan Tuesday, February 7, 2012 1:57 AM
    Friday, January 27, 2012 4:25 PM