Locations of visitors to this page
Onteora Software - December 2007

Onteora Software

Ken Tucker's Blog

About the author

Author Name is someone.
E-mail me Send mail

Recent posts

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Welcome to BlogEngine.NET 1.3

If you see this post it means that BlogEngine.NET 1.3 is running and the hard part of creating your own blog is done. There is only one thing you need to do from this point on to take full advantage of the blog and that is to set up the first author profile.

Write Permissions

To be able to log in to the blog and writing posts, you need to enable write permissions on the App_Data folder. If you’re blog is hosted at a hosting provider, you can either log into your account’s admin page or call the support. You need write permissions on the App_Data folder because all posts and comments are saved as XML files and placed in the App_Data folder.

Username and password

When you've got write permissions to the App_Data folder, you need to change the username and password. Find the sign-in link located either at the bottom or top of the page depending on your current theme and click it. Now enter "admin" in both the username and password fields and click the button. You will now see an admin menu appear. It has a link to the "Users" admin page. From there you can change the username and password.

On the web

You can find BlogEngine.NET on the official website. Here you'll find tutorials, documentation, tips and tricks and much more. The ongoing development of BlogEngine.NET can be followed at CodePlex where the daily builds will be published for anyone to download.

Good luck and happy writing.

The BlogEngine.NET team

Currently rated 4.4 by 3 people

  • Currently 4.4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,
Categories: General
Posted by Admin on Friday, December 21, 2007 7:00 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Using the ExcelPackage class on a web page

Dr. John Tunicliffe wrote a nice class for creating excel 2007 spreadsheets and was nice enough to post his work on the codeplex web site. 

 

http://www.codeplex.com/ExcelPackage

 

I was looking to use the ExcelPackage to create a spreadsheet on a website with out having to save the spreadsheet on the server first.  Well to do this we are going to have to modify the ExcelPackage class to have an constructor which accepts a stream.  After you download the ExcelPackage class from codeplex add the following code to ExcelPackage.cs contructors region.

 

        #region ExcelPackage Constructors
        /// <summary>
        /// Creates a new instance of the ExcelPackage class based on a stream.
        /// </summary>
        /// <param name="stream">Creates a new ExcelPackage from a stream</param>
        public ExcelPackage(Stream stream)
        {
            _package = Package.Open(stream, FileMode.OpenOrCreate);
            // save a temporary part to create the default application/xml content type
            Uri uriDefaultContentType = new Uri("/default.xml", UriKind.Relative);
            PackagePart partTemp = _package.CreatePart(uriDefaultContentType, "application/xml");

            XmlDocument workbook = Workbook.WorkbookXml; // this will create the workbook xml in the package

            // create the relationship to the main part
            _package.CreateRelationship(Workbook.WorkbookUri, TargetMode.Internal, schemaRelationships + "/officeDocument");

            // remove the temporary part that created the default xml content type
            _package.DeletePart(uriDefaultContentType);
        }

Once you compile the class we can add it as a reference to a website which targets the .Net framework 3.0 or 3.5.

So to write a spreadsheet to webpage we need to first create a MemoryStream to save the spreadsheet to.  I use a MemoryStream because the Response.OutputStream will give you an error about the FileMode or FileAccess type not being valid for this stream. Once we write the spreadsheet to the MemoryStream  set the Response's ContextType. Then we can write the MemoryStream to the webpage.

Imports OfficeOpenXml
Imports System.IO

Partial Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim ms As New MemoryStream

        Using pack As New ExcelPackage(ms)
            Dim ws As ExcelWorksheet = pack.Workbook.Worksheets.Add("Sheet1")
            ws.Cell(1, 1).Value = "Product Name"
            ws.Column(1).Width = 30
            ws.Cell(1, 2).Value = "Price"
            ws.Column(2).Width = 10

            For r As Integer = 0 To 9
                ws.Cell(r + 2, 1).Value = "Product " & r.ToString
                ws.Cell(r + 2, 2).Value = r.ToString()
            Next

            pack.Workbook.Properties.Author = "Ken Tucker"
            pack.Workbook.Properties.Title = "Create spreadsheet from web"
            pack.Save()
        End Using
        Response.ContentType = "application/vnd.openxmlformats"
        Response.AddHeader("Content-Disposition", "attachment; filename= Data.xlsx;")
        Response.OutputStream.Write(ms.GetBuffer, 0, CInt(ms.Length))
        Response.Flush()
        Response.Close()
        Response.End()

    End Sub

End Class

Hope this helps


kick it on DotNetKicks.com

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: open xml
Posted by Ken Tucker on Monday, December 17, 2007 7:12 AM
Permalink | Comments (1) | Post RSSRSS comment feed

Speech Recognition

The dot net framework 3.0 added the system.speech namespace.  One of the new classes they added is the SpeechRecognizer.  The speech recognizer class has a SpeechRecognized event which you can use to make your application accept dictation.

 

For this example you need to create a .net 3.0 or .net 3.5 windows forms app.  Place a multi-line textbox on the form. 

 

 

Imports System.Speech
Imports System.Speech.Recognition

Public Class Form1
    Dim recognizer As New SpeechRecognizer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddHandler recognizer.SpeechRecognized, AddressOf SpeechRecognized
    End Sub

    Private Sub SpeechRecognized(ByVal sender As Object, ByVal e As SpeechRecognizedEventArgs)
        TextBox1.Text &= e.Result.Text
    End Sub
End Class

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: VB | Speech
Posted by Ken Tucker on Tuesday, December 11, 2007 9:53 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Changing the target cpu in VB express 2008

When you are running a VB express 2008 on a 64 bit operating system there are times you need to compile the app as a 32bit.   One example is if you need to open an access database.  There is not a 64 bit version of jet. To force your app to use the 32 bit version you need to compile the app for the x86 version of the framework.

 

Unfortunately there is no built in way to change the target cpu in VB express 2008.  Your best bet is get a copy of Visual studio but if this is not an option you can change it with notepad.  Make sure you back up your applications project file before you make any changes.

 

Open up Notepad and open the YourProject.vbproj and you will find a section like this

 

 

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  <DebugSymbols>true</DebugSymbols>
  <DebugType>full</DebugType>
  <DefineDebug>true</DefineDebug>
  <DefineTrace>true</DefineTrace>
  <OutputPath>bin\Debug\</OutputPath>
  <DocumentationFile>LinqToDataSet.xml</DocumentationFile>
  <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
  <DebugType>pdbonly</DebugType>
  <DefineDebug>false</DefineDebug>
  <DefineTrace>true</DefineTrace>
  <Optimize>true</Optimize>
  <OutputPath>bin\Release\</OutputPath>
  <DocumentationFile>LinqToDataSet.xml</DocumentationFile>
  <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
</PropertyGroup>

To change the target cpu add

<PlatformTarget>x86</PlatformTarget>

just before </PropertyGroup> in the Debug and Release sections

It should look like this when done

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
   <DebugSymbols>true</DebugSymbols>
   <DebugType>full</DebugType>
   <DefineDebug>true</DefineDebug>
   <DefineTrace>true</DefineTrace>
   <OutputPath>bin\Debug\</OutputPath>
   <DocumentationFile>LinqGroupBy.xml</DocumentationFile>
   <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
   <PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
   <DebugType>pdbonly</DebugType>
   <DefineDebug>false</DefineDebug>
   <DefineTrace>true</DefineTrace>
   <Optimize>true</Optimize>
   <OutputPath>bin\Release\</OutputPath>
   <DocumentationFile>LinqGroupBy.xml</DocumentationFile>
   <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
   <PlatformTarget>x86</PlatformTarget>
</PropertyGroup>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: VB | 64 bit
Posted by Ken Tucker on Friday, December 07, 2007 5:35 AM
Permalink | Comments (2) | Post RSSRSS comment feed

Use Linq to create a random list of numbers

Here is a simple linq query which places the numbers from 1 and 150 in a random order

 

Dim r As New Random(Now.Ticks Mod Int32.MaxValue)

Dim rndLst = From l In (From num In Enumerable.Range(1, 150) _
             Select New With {.Num = num, .pos = r.Next(1, 150)}) _
             Order By l.pos _
             Select l.Num

For Each i In rndLst
    Console.WriteLine(i)
Next


kick it on DotNetKicks.com

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Linq | VB | VS 2008
Posted by Ken Tucker on Monday, December 03, 2007 2:14 PM
Permalink | Comments (0) | Post RSSRSS comment feed