الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

سؤال بخصوص فتح الملفات النصية داخل المتصفح

بدأه easy_3a3 في 17 سبتمبر 2011 · 14 رد · 849 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

انا كنت لما افتح ملفات الوورد او اي لف تاني داخل ال متصفح باستخدام <iframe>

الامر يزبط عادي اما هلا بطل ينفع ليش طيب صار يعطيني اني افتحة او احملة ويفتح لحالة يعني مش ضمن الاكسبلورر

#2

السلام عليكم ورحمه الله وبركاته

اختي جرب الكود التالي لعرض الملف داخل المتصفح

File file = new File(Server.MapPath("test.doc"));
Response.ClearContent();
Response.AddHeader("Content-Disposition", "inline;filename=" + file.Name);
Respone.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/msword";
Reponse.TransmitFile(file.FullName);
Response.End();

شوفي الرابط التالي للفائدة http://support.microsoft.com/kb/306654

تم تعديل هذه المشاركة بواسطة VB Helper في 17 سبتمبر 2011 في 09:59

.:: Wish to become better and better ::.

#3

اعطاني هذا الخطأ

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0723: Cannot declare a variable of static type 'System.IO.File'

Source Error:

Line 20: protected void Button1_Click(object sender, EventArgs e)

Line 21: {

Line 22: File file = new File(Server.MapPath("test.doc"));

Line 23: Response.ClearContent();

Line 24: Response.AddHeader("Content-Disposition", "inline;filename=" + file.Name);

#4

السلام عليكم ورحمه الله وبركاته

اختي عذرا قومي بتغيير السطر الاول الى

FileInfo file = new FileInfo(Server.MapPath("test.doc"));

ولاتنسي تصريح System.IO وان شاء الله كل شيء سيضبط

.:: Wish to become better and better ::.

#5

اخي نفس المشكلة وانا شفت لك مثال سابق عن ال pdf بنفس الطريقة وكان مرة يزبط ومرة يفتح بدون ما يفتح بال متصفح

شوف الصورة اخي هيك بعطيني

post-193975-014837700 1316272835_thumb.j

المرفقات
fgg.jpg
#6

للتذكير

#7

السلام عليكم

هذا التابع لقراءة محتويات ملف word كـ Text

يستعمل المكتبة

using Microsoft.Office.Interop.Word;

لإضافة المكتبة : ToolBox --> choos Items -->COM Components --> Microsoft.Office.Interop.Word

    private void readFileContent(string path)
    {
        Microsoft.Office.Interop.Word.ApplicationClass wordApp = new ApplicationClass();
        object file = path;
        object nullobj = System.Reflection.Missing.Value;

        Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(
        ref file, ref nullobj, ref nullobj,
        ref nullobj, ref nullobj, ref nullobj,
        ref nullobj, ref nullobj, ref nullobj,
        ref nullobj, ref nullobj, ref nullobj);
        doc.ActiveWindow.Selection.WholeStory();
        doc.ActiveWindow.Selection.Copy();
        string txt = doc.Content.Text;
        doc.Close(ref nullobj, ref nullobj, ref nullobj);
        wordApp.Quit(ref nullobj, ref nullobj, ref nullobj);
        Response.Write(txt);
    }

نستدعي التابع و ندرج مسار الملف المطلوب

readFileContent(Server.MapPath("test3.docx"));

فيقوم بكتابة محتويات الملف في الصفحة و طبعا يمكن كتابتها في أي Control

و إذا كان عند أحد فكرة عن قراءة التنسيقات أيضا فليعلمنا إياها جزاه الله خيرا

#8
باسل بوشناق كتب:

السلام عليكم

هذا التابع لقراءة محتويات ملف word كـ Text

يستعمل المكتبة

using Microsoft.Office.Interop.Word;

لإضافة المكتبة : ToolBox --> choos Items -->COM Components --> Microsoft.Office.Interop.Word

    private void readFileContent(string path)
    {
        Microsoft.Office.Interop.Word.ApplicationClass wordApp = new ApplicationClass();
        object file = path;
        object nullobj = System.Reflection.Missing.Value;

        Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(
        ref file, ref nullobj, ref nullobj,
        ref nullobj, ref nullobj, ref nullobj,
        ref nullobj, ref nullobj, ref nullobj,
        ref nullobj, ref nullobj, ref nullobj);
        doc.ActiveWindow.Selection.WholeStory();
        doc.ActiveWindow.Selection.Copy();
        string txt = doc.Content.Text;
        doc.Close(ref nullobj, ref nullobj, ref nullobj);
        wordApp.Quit(ref nullobj, ref nullobj, ref nullobj);
        Response.Write(txt);
    }

نستدعي التابع و ندرج مسار الملف المطلوب

readFileContent(Server.MapPath("test3.docx"));

فيقوم بكتابة محتويات الملف في الصفحة و طبعا يمكن كتابتها في أي Control

و إذا كان عند أحد فكرة عن قراءة التنسيقات أيضا فليعلمنا إياها جزاه الله خيرا

شكراً اخي الكريم

بس انا دورة على المكتبة

Microsoft.Office.Interop.Wod

وما لقيتها وين بجدها اخي ما لقيتها مع المكتبات التانية

#9

اخي هل للمكتبة اسم آخر

؟؟؟

#10

السلام عليكم ورحمه الله وبركاته

اختي قومي باضافتها من Add Reference

.:: Wish to become better and better ::.

#11

مش موجودة

#12

السلام عليكم ورحمة الله وبركاته

Add Reference

From Com tab select

Microsoft Word 12.0 Object Library اذا كنتي تستخدمين اوفيس 07

اما اذا كنتي من مستخدمين اوفيس 2003 سيظهر باسم Microsoft Word 11.0 Object Library

((إِنَّ اللَّهَ وَمَلائِكَتَهُ يُصَلُّونَ عَلَى النَّبِيِّ يَا أَيُّهَا الَّذِينَ آمَنُوا صَلُّوا عَلَيْهِ وَسَلِّمُوا تَسْلِيمًا))

#13
Rose Muhammed كتب:

السلام عليكم ورحمة الله وبركاته

Add Reference

From Com tab select

Microsoft Word 12.0 Object Library اذا كنتي تستخدمين اوفيس 07

اما اذا كنتي من مستخدمين اوفيس 2003 سيظهر باسم Microsoft Word 11.0 Object Library

وعليكم السلام ورحمة الله وبركاته

اخي الكود فيه مشكلة طلعلي خط ازرق تحت كلمات word ولما حذفت الكلمات برضة اعطاني خطا

#14

اخي انا بشتغل ويب asp.net

ممكن عشان هيك ما بشتغل

طيب جملة

readFileContent(Server.MapPath("test3.docx"));

جملة ويب ليش عندك بشتغل وعندي لا

ارجو تزويدي بمثال

#15

حملة المكتبة من الانترنت ولما اجيت اعمل choose item ما زبط كمان عطاني هاد المسج

post-193975-083718100 1316672333_thumb.j

المرفقات
Untitled.jpg

تم تعديل هذه المشاركة بواسطة easy_3a3 في 22 سبتمبر 2011 في 09:19

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…