Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Please help me how to set filters in Asp.net

I have tried

C#
app.GetSaveAsFilename("Customer Details","*.xls");


But I am getting error.

Thanks in advance
Posted
Comments
ZurdoDev 1-Oct-13 8:09am    
1. What's the error?
2. app.GetSaveAsFilename - Isn't that an Office function? Aren't you doing asp.net?
3. What are you doing?
JoCodes 1-Oct-13 8:10am    
Filters in what? Can you please elaborate on what exactly you want to achieve???

you can use like this.

C#
string fileFilter = "Excel Workbook (*.xlsx),*.xlsx," +

                               "Excel Macro-Enabled Workbook (*.xlsm),*.xlsm," +

                               //"Excel Binary Workbook (*.xlsb),*.xlsb," +

                               "Excel 97-2003 Workbook (*.xls),*.xls," +

                               //"XML Data (*.xml),*.xml," +

                               //"Single File Web Page (*.mht; *.mhtml),*.mht;*.mhtml," +

                               //"Web Page (*.htm; *.html),*.htm;*.html," +

                               "Excel Template (*.xltx),*.xltx," +

                               "Excel Macro-Enbaled Template (*.xltm),*.xltm," +

                               //"Excel 97-2003 Template (*.xlt),*.xlt," +

                               //"Text (Tab delimited)(*.txt),*.txt," +

                               "CSV (Comma delimited)(*.csv),*.csv,";

                               //"PDF (*.pdf),*.pdf," +

                               //"XPS Document (*.xps),*.xps,";



           // Launch a SaveAs dialog that we can control

           object sa = Wb.Application.GetSaveAsFilename(m, fileFilter.TrimEnd(new char[] { ',' }), m, m, m);



or VB code like this

VB
fileSaveName = Application.GetSaveAsFilename( _
 fileFilter:="Text Files (*.txt), *.txt")
If fileSaveName <> False Then
 MsgBox "Save as " & fileSaveName
End If
 
Share this answer
 
v2
Comments
srmohanr 1-Oct-13 8:15am    
........
........
app.GetSaveAsFilename(fileName, fileFilter.TrimEnd(new char[] { ',' }));
app.Workbooks.Close();

I have used this code. And then I am getting 'Do u want to save the Sheet'. If I press 'No', file is not saving. How can I achieve this. Please help.
i think you need to press "YES" to save the sheet.
 
Share this answer
 
Comments
srmohanr 2-Oct-13 0:51am    
Please tell me, is there any other way to achieve this from code behind

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900