工作表不保存在服务器目录中 [英] Worksheets not save at server directory

查看:99
本文介绍了工作表不保存在服务器目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将数据表转换为excel格式。这适用于本地系统但不能使用server..file不能保存在服务器位置。



我申请完全安全但仍然无法在服务器位置保存excel文件。



请指出如何在服务器位置保存excel文件。



var workbook2 = new ExcelFile();



//将所有表从DataSet导入新文件。

foreach(dataSet.Tables中的DataTable dataTable)

{

//将新工作表添加到文件中。

var worksheet = workbook2。 Worksheets.Add(dataTable.TableName);



//更改DataTable中第一个单元格的值。

dataTable.Rows [ 0] [0] =这是新文件!;



//将数据从DataTable插入工作表,从单元格A1开始。

worksheet.InsertDataTable(dataTable,

new InsertDataTableOptions(A1){ColumnHeaders = true});

}



我尝试过:



var workbook2 = new ExcelFile();



//将所有表从DataSet导入新文件。

foreach(dataSet.Tables中的DataTable dataTable)

{

//将新工作表添加到文件中。

var worksheet = workbook2.Worksheets .Add(dataTable.TableName);



//更改DataTable中第一个单元格的值。

dataTable.Rows [0 ] [0] =这是新文件!;



//将数据从DataTable插入工作表,从单元格A1开始。

worksheet.InsertDataTable(dataTable,

new InsertDataTableOptions(A1){ColumnHeaders = true});

}

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 });
}

推荐答案

因为您的代码在客户端上运行,所以它默认访问客户端文件系统 - 而不是服务器。要在服务器上保存,您需要直接通过 \\ServerName \ ShareName \ filepath 专门引用服务器文件系统(假设您的用户具有相应的权限)共享)或直接将服务器共享映射为客户端系统中的驱动器号。
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.


这篇关于工作表不保存在服务器目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆