0

I have a console application in which we are creating xlsx files using OPENXML, we are able to create xlsx file & save it into specific folder in application.

But Now we want to show that file as a Save/Open dialog pop up. Then we can able to specify a particular path to save/ to open the existing files.

I am new to this OpenXml, Can anyone please help me on this to proceed further? How can I acheive this? Do we have any built-in DLL for this?

Thanks.

SuryaKavitha
  • 493
  • 5
  • 16
  • 36
  • I think using search engine o search for text from your post [C# show that file as a Save/Open dialog](http://www.bing.com/search?q=C%23+show+that+file+as+a+Save%2FOpen+dialog+&qs=n&form=QBRE&pq=c%23+show+that+file+as+a+save%2Fopen+dialog+) is accepatable approach... [How to: Save Files Using the SaveFileDialog Component](http://msdn.microsoft.com/en-us/library/sfezx97z.aspx) – Alexei Levenkov Jun 28 '13 at 06:37
  • Its not a normal C# code, We have to do this by OpenXML – SuryaKavitha Jun 28 '13 at 06:59

1 Answers1

1

se the Save file dialog. It will prompts the user to select a location for saving a file. After that you can use saveFileDialog.FileName.ToString() property to get the full path. See the sample code below:

//Save a file in a particular format as specified in the saveAsType parameter
     private void OpenSaveFileDialog(int saveAsType)
     {
        SaveFileDialog saveFileDialog = new SaveFileDialog();
        saveFileDialog.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments);
        saveFileDialog.Filter = "CSV|*.csv|Excel|*.xlsx";
        saveFileDialog.FilterIndex = saveAsType;
        saveFileDialog.Title = "Save Data";
        saveFileDialog.FileName = "My File";
        saveFileDialog.ShowDialog();

        if (saveFileDialog.FileName != "")
        {
            //File Path =   m_fileName         
             m_fileName = saveFileDialog.FileName.ToString();
             //FilterIndex property is one-based.
             switch (saveFileDialog.FilterIndex)
             {
                case 1:
                    m_fileType = 1;
                    break;
                case 2:
                    m_fileType = 2;
                    break;
              }
        }
      }

Ref:http://msdn.microsoft.com/en-us//library/system.windows.forms.savefiledialog.aspx

Zabed Akbar
  • 537
  • 1
  • 8
  • 20