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.

2

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.