首先,我将Excel文档转换为字节并将它们存储在SQL SERVER 2008
中string[] TotalCount = Directory.GetFiles(FileDropLocation);
foreach (string item in TotalCount)
{
FileStream fs = new FileStream(item, FileMode.Open, FileAccess.Read);
string fileName = Path.GetFileName(item);
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32)fs.Length);
//insert the file into database
string strQuery = "insert into tblFiles(Name, ContentType, Data) values (@Name, @ContentType, @Data)";
SqlCommand cmd = new SqlCommand(strQuery);
cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = fileName;
cmd.Parameters.Add("@ContentType", SqlDbType.VarChar).Value = contenttype;
cmd.Parameters.Add("@Data", SqlDbType.Binary).Value = bytes;
InsertUpdateData(cmd);
lblMessage.ForeColor = System.Drawing.Color.Green;
lblMessage.Text = "File Uploaded Successfully";
}
其次,我希望将其检索为PDF而不是excel并在我的aspx页面上显示它。 可以这样做吗? 请在此部分获得帮助。
先谢谢, HRG
答案 0 :(得分:0)
如果您可以将Microsoft Excel安装到Web服务器上,则可以使用Excel's save as PDF功能进行转换。这使您可以非常轻松地基于Excel配置和输出PDF。它不会弹出服务器上的Excel窗口;)
答案 1 :(得分:0)
您希望按以下方式执行某些操作: