Click here to Skip to main content
15,905,781 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I converted datatable into excel format.This is working properly with local system but not working with server..file is not save at server location.

I apply full security but still unable to save excel file at server location.

Please,suggests that how can I save excel file on server location.

var workbook2 = new ExcelFile();

// Imports all tables from DataSet to new file.
foreach (DataTable dataTable in dataSet.Tables)
{
// Add new worksheet to the file.
var worksheet = workbook2.Worksheets.Add(dataTable.TableName);

// Change the value of the first cell in the DataTable.
dataTable.Rows[0][0] = "This is new file!";

// Insert the data from DataTable to the worksheet starting at cell "A1".
worksheet.InsertDataTable(dataTable,
new InsertDataTableOptions("A1") { ColumnHeaders = true });
}

What I have tried:

var workbook2 = new ExcelFile();

// Imports all tables from DataSet to new file.
foreach (DataTable dataTable in dataSet.Tables)
{
// Add new worksheet to the file.
var worksheet = workbook2.Worksheets.Add(dataTable.TableName);

// Change the value of the first cell in the DataTable.
dataTable.Rows[0][0] = "This is new file!";

// Insert the data from DataTable to the worksheet starting at cell "A1".
worksheet.InsertDataTable(dataTable,
new InsertDataTableOptions("A1") { ColumnHeaders = true });
}
Posted
Updated 21-Apr-17 21:34pm
Comments
piyushpiyush 22-Apr-17 2:13am    
Ws.SaveAs([footpath]) only working with local system...on server location file save action not working.. give the solutions for how this is working with server path.

1 solution

Because your code runs on the client, it by default accesses the client file system - not the server. To save at the server you will need to specifically reference the server file system either directly via \\ServerName\ShareName\filepath (assuming your user has appropriate permissions for the share) or by directly mapping the server share as a drive letter in your client system.
 
Share this answer
 
Comments
piyushpiyush 22-Apr-17 10:00am    
Server name not support with http format by using ws.save(filepath).

Here file path not support in http and ftp format.

How can I give format of http or ftp.
OriginalGriff 22-Apr-17 10:26am    
Don't give HTTP or FTP names!
Use \\ServerName or a mapped drive letter.

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